home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 July
/
EnigmA AMIGA RUN 09 (1996)(G.R. Edizioni)(IT)[!][issue 1996-07 & 08][EARSAN CD VIII].iso
/
earcd
/
util4
/
tnmtr431.lha
/
TinyMeter
/
Source
/
TinyMeter_prefs
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-05-14
|
97KB
|
3,047 lines
/// headers
/* MUI */
#include <libraries/mui.h>
/* System */
#include <dos/dos.h>
#include <graphics/gfxmacros.h>
#include <workbench/workbench.h>
#include <exec/memory.h>
#include <datatypes/pictureclass.h>
#include <libraries/locale.h>
/* Prototypes */
#include <clib/alib_protos.h>
#include <clib/exec_protos.h>
#include <clib/dos_protos.h>
#include <clib/icon_protos.h>
#include <clib/graphics_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/utility_protos.h>
#include <clib/asl_protos.h>
#ifndef __GNUC__
#include <clib/muimaster_protos.h>
#else
#include <inline/muimaster.h>
#endif
/* ANSI C */
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#ifndef MAKE_ID
#define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
#endif
///
#define STRINGARRAY YES
#include "TinyMeterPrefs.lh"
#include "tinymeter.h"
static struct MUI_CustomClass *CL_FieldsList;
static struct MUI_CustomClass *CL_ChooseFields;
static struct MUI_CustomClass *CL_MainWindow;
static struct MUI_CustomClass *CL_Composer;
static struct MUI_CustomClass *CL_Launcher;
#define USE_ABOUT_COLORS YES
#define USE_ABOUT_HEADER YES
#define USE_ABOUT_BODY YES
#define USE_LOGO_COLORS YES
#define USE_LOGO_HEADER YES
#define USE_LOGO_BODY YES
#define USE_HEADER_LOGO_COLORS YES
#define USE_HEADER_LOGO_HEADER YES
#define USE_HEADER_LOGO_BODY YES
#define USE_QUESTION_COLORS YES
#define USE_QUESTION_HEADER YES
#define USE_QUESTION_BODY YES
enum { MEN_PROJECT=1,MEN_ABOUT,MEN_OPEN,MEN_SAVE,MEN_QUIT,CMP_LOAD, CMP_SAVE, CMP_CANCEL, CMP_PROJECT };
/*************************************************************************************************/
/* misc funcs */
/*************************************************************************************************/
///
ULONG DoSuperNew(struct IClass *cl,Object *obj,ULONG tag1,...)
{
return(DoSuperMethod(cl,obj,OM_NEW,&tag1,NULL));
}
LONG xget(Object *obj,ULONG attribute)
{
LONG x;
get(obj,attribute,&x);
return(x);
}
initColor(struct GAU_Color *col,Object *obj)
{
struct MUI_PenSpec pspec;
if(col->pen==TRUE)
{
sprintf(&pspec.buf[0],"p%d\0",col->red);
set(obj,MUIA_Pendisplay_Spec,&pspec);
}
else
{
sprintf(&pspec.buf[0],"r%08lx,%08lx,%08lx\0",col->red,col->green,col->blue);
set(obj,MUIA_Pendisplay_Spec,&pspec);
}
}
getColor(struct GAU_Color *col,Object *obj)
{
struct MUI_PenSpec *pspec;
char *buf;
ULONG *dummy1,dummy2,dummy3;
get(obj,MUIA_Pendisplay_Spec,&pspec);
if(buf=(char *)AllocVec(256L,MEMF_CLEAR))
{
strcpy(buf,&pspec->buf[0]);
if(buf[0])
{
switch (buf[0])
{
case 'r':
col->pen=(UWORD)FALSE;
sscanf(buf+1,"%lx,%lx,%lx",&dummy1,&dummy2,&dummy3);
col->red=(ULONG)dummy1;
col->green=(ULONG)dummy2;
col->blue=(ULONG)dummy3;
break;
case 'p':
col->pen=(UWORD)TRUE;
sscanf(buf+1,"%ld",&col->red);
break;
case 'm':
MUI_RequestA(NULL,NULL,0,"TinyMeterPrefs","BAD LUCK!","Please do not use MUI colors.\nThey are not supported by TinyMeter!\n\nUse Colormap or a RBG color instead.",NULL);
break;
}
}
FreeVec(buf);
}
}
__saveds __asm void IntuiMsgFunc(__a1 struct IntuiMessage *imsg,__a2 struct FileRequester *req)
{
if (imsg->Class==IDCMP_REFRESHWINDOW)
DoMethod(req->fr_UserData,MUIM_Application_CheckRefresh);
}
char *getfilename(Object *win,char *title,char *pattern,BOOL save)
{
static char buf[512];
struct FileRequester *req;
struct Window *w;
static LONG left=-1,top=-1,width=-1,height=-1;
Object *app = (Object *)xget(win,MUIA_ApplicationObject);
char *res = NULL;
static const struct Hook IntuiMsgHook = { { 0,0 },(VOID *)IntuiMsgFunc,NULL,NULL };
get(win,MUIA_Window_Window,&w);
if (left==-1)
{
left = w->LeftEdge+w->BorderLeft+2;
top = w->TopEdge+w->BorderTop+2;
width = w->Width-w->BorderLeft-w->BorderRight-4;
height = w->Height-w->BorderTop-w->BorderBottom-4;
}
if (req=MUI_AllocAslRequestTags(ASL_FileRequest,
ASLFR_Window, w,
ASLFR_TitleText, title,
ASLFR_InitialLeftEdge, left,
ASLFR_InitialTopEdge , top,
ASLFR_InitialWidth , width,
ASLFR_InitialHeight , height,
ASLFR_InitialPattern , pattern,
ASLFR_DoSaveMode , save,
ASLFR_DoPatterns , TRUE,
ASLFR_RejectIcons , TRUE,
ASLFR_UserData , app,
ASLFR_IntuiMsgFunc , &IntuiMsgHook,
TAG_DONE))
{
set(app,MUIA_Application_Sleep,TRUE);
if (MUI_AslRequestTags(req,TAG_DONE))
{
if (*req->fr_File)
{
res = buf;
strcpy(buf,req->fr_Drawer);
AddPart(buf,req->fr_File,sizeof(buf));
}
left = req->fr_LeftEdge;
top = req->fr_TopEdge;
width = req->fr_Width;
height = req->fr_Height;
}
MUI_FreeAslRequest(req);
set(app,MUIA_Application_Sleep,FALSE);
}
return(res);
}
///
extern struct Library *SysBase,
*IntuitionBase,
*UtilityBase,
*GfxBase,
*DOSBase,
*IconBase;
struct Library *MUIMasterBase,
*LocaleBase;
struct tm_data *maindata;
struct Catalog *Catalog;
/*************************************************************************************************/
/* locale stuff */
/*************************************************************************************************/
///
char *GetStr(int num)
{
struct AppString *as = (struct AppString *)AppStrings;
while (as->as_ID != num) as++;
if (LocaleBase && Catalog) return(GetCatalogStr(Catalog,num,as->as_Str));
return((char *)as->as_Str);
}
VOID LocalizeStringArray(char **array)
{
char **x;
for (x=array;*x;x++) *x = GetStr((int)*x);
}
VOID LocalizeNewMenu(struct NewMenu *nm)
{
for (;nm->nm_Type!=NM_END;nm++) if (nm->nm_Label != NM_BARLABEL) nm->nm_Label = GetStr((int)nm->nm_Label);
}
VOID InitLocale(VOID)
{
if (LocaleBase = OpenLibrary("locale.library",38L)) Catalog = (struct Catalog *)OpenCatalog(NULL,"TinyMeterPrefs.catalog",TAG_DONE);
}
VOID ExitLocale(VOID)
{
if (Catalog) { CloseCatalog(Catalog); Catalog =NULL; }
if (LocaleBase) { CloseLibrary(LocaleBase); LocaleBase=NULL; }
}
Object *MakePen()
{
return(MUI_NewObject(MUIC_Poppen, MUIA_CycleChain, 1, MUIA_Window_Title, GetStr(MO_MakePen), MUIA_Weight, 0, TAG_DONE));
}
///
/*************************************************/
/* some pics */
/*************************************************/
#include "about.c"
#include "header_logo.c"
#include "question.c"
#include "logo.c"
/*************************************************/
/* default settings */
/*************************************************/
///
struct tm_sys_set default_set=
{
"TM40",
1,
10,
10,
400,
2,
"Workbench",
"XHelvetica.font",
11,
bg_file,
"hd0:prefs/patterns/leather",
-3,
FALSE,0x55555555,0x55555555,0x55555555,
5,
1,
0,
TRUE,
win_normal,
0,
4,
4,
8,
8,
bd_standard,
FALSE,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
FALSE,0x0,0x0,0x0,
idle_own
};
struct tm_gau_set g4=
{
typ_volume,
typ_histmeter,
200,
"Quill.font",
11,
"ChipMem",
"HD1: %kd kb,%p%% free",
"HD1:",
FALSE,
ind_right,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
TRUE,
TRUE,2,0,0,
TRUE,2,0,0,
FALSE,0,0xFFFFFFFF,0,
FALSE,0,0,0xFFFFFFFF,
FALSE,0xFFFFFFFF,0,0,
TRUE,2,0,0,
TRUE,1,0,0,
TRUE,1,0,0,
NULL
};
struct tm_gau_set g3=
{
typ_idle,
typ_histmeter,
200,
"Quill.font",
11,
"ChipMem",
"CPU %p%% free",
"",
FALSE,
ind_right,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
TRUE,
TRUE,2,0,0,
TRUE,2,0,0,
FALSE,0,0xFFFFFFFF,0,
FALSE,0,0,0xFFFFFFFF,
FALSE,0xFFFFFFFF,0,0,
TRUE,2,0,0,
TRUE,1,0,0,
TRUE,1,0,0,
&g4
};
struct tm_gau_set g2=
{
typ_fast,
typ_gauge,
20,
"XHelvetica.font",
11,
"FastMem",
"%td Bytes free",
"",
FALSE,
ind_right,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
FALSE,
TRUE,2,0,0,
TRUE,2,0,0,
FALSE,0,0xFFFFFFFF,0,
FALSE,0,0,0xFFFFFFFF,
FALSE,0xFFFFFFFF,0,0,
TRUE,2,0,0,
TRUE,1,0,0,
TRUE,0,0,0,
&g3,
};
struct tm_gau_set g1=
{
typ_chip,
typ_gauge,
20,
"XHelvetica.font",
11,
"ChipMem",
"%td Bytes free",
"",
FALSE,
ind_right,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
FALSE,
TRUE,2,0,0,
TRUE,2,0,0,
FALSE,0,0xFFFFFFFF,0,
FALSE,0,0,0xFFFFFFFF,
FALSE,0xFFFFFFFF,0,0,
TRUE,2,0,0,
TRUE,1,0,0,
TRUE,0,0,0,
&g2
};
struct tm_gau_set default_gauge=
{
NULL,
typ_gauge,
80,
"topaz.font",
8,
"",
"",
"",
FALSE,
ind_right,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
TRUE,
TRUE,2,0,0,
TRUE,2,0,0,
FALSE,0,0xFFFFFFFF,0,
FALSE,0,0,0xFFFFFFFF,
FALSE,0xFFFFFFFF,0,0,
TRUE,2,0,0,
TRUE,1,0,0,
TRUE,0,0,0,
NULL
};
struct tm_gau_set default_launcher=
{
NULL,
typ_gauge,
80,
"topaz.font",
8,
"",
"",
"",
FALSE,
ind_right,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
TRUE,
TRUE,1,0,0,
TRUE,1,0,0,
FALSE,0,0xFFFFFFFF,0,
TRUE,1,0,0,
TRUE,3,0,0,
TRUE,2,0,0,
TRUE,1,0,0,
TRUE,0,0,0,
NULL
};
///
/*************************************************/
/* Drag & Drop lists */
/*************************************************/
/******************************************/
/* some hooks */
/******************************************/
///
char *gau_types[]=
{
(STRPTR)MDL_typ_space,
(STRPTR)MDL_typ_total,
(STRPTR)MDL_typ_chip,
(STRPTR)MDL_typ_fast,
(STRPTR)MDL_typ_volume,
(STRPTR)MDL_typ_cpu,
(STRPTR)MDL_typ_retina,
(STRPTR)MDL_typ_largest_chip,
(STRPTR)MDL_typ_largest_fast,
(STRPTR)MDL_typ_largest_total,
(STRPTR)MDL_typ_largest_retina,
(STRPTR)MDL_typ_clock,
(STRPTR)MDL_typ_simplelauncher,
(STRPTR)MDL_typ_iconlauncher,
0L,
};
__geta4 ULONG gau_consfunc(__a1 struct tm_gau_set *src)
{
return(src);
}
__geta4 void gau_desfunc(__a1 struct tm_gau_set *src)
{
FreeVec(src);
}
__geta4 ULONG gau_dispfunc(__a2 char **array,__a1 struct tm_gau_set *src)
{
if(src->type!=0)
{
*array++ = gau_types[src->type];
if(src->type==typ_volume)
{
*array = &src->expansion[0];
}
else *array = "";
}
else
{
*array++ = "-----------------";
*array = "";
}
return(0L);
}
static const struct Hook gau_ConstructHook = { { 0,0 }, (void *)gau_consfunc, NULL, NULL };
static const struct Hook gau_DestructHook = { { 0,0 }, (void *)gau_desfunc , NULL, NULL };
static const struct Hook gau_DisplayHook = { { 0,0 }, (void *)gau_dispfunc, NULL, NULL };
///
/******************************************/
/* FieldsList class */
/******************************************/
///
struct FieldsList_Data
{
LONG dummy;
};
ULONG FieldsList_DragQuery(struct IClass *cl,Object *obj,struct MUIP_DragDrop *msg)
{
if (msg->obj==obj) return(DoSuperMethodA(cl,obj,msg));
else if (msg->obj==(Object *)muiUserData(obj)) return(MUIV_DragQuery_Accept);
else return(MUIV_DragQuery_Refuse);
}
ULONG FieldsList_DragDrop(struct IClass *cl,Object *obj,struct MUIP_DragDrop *msg)
{
if (msg->obj==obj) return(DoSuperMethodA(cl,obj,msg));
else
{
struct tm_gau_set *entry;
LONG dropmark;
LONG sortable;
LONG active;
get(obj,MUIA_List_DragSortable,&sortable);
if (sortable)
{
get(msg->obj,MUIA_List_Active,&active);
if(entry=(struct tm_gau_set *)AllocVec(sizeof(struct tm_gau_set),MEMF_CLEAR))
{
if((active==typ_simplelauncher)||(active==typ_iconlauncher))
{
CopyMem(&default_launcher,entry, sizeof(struct tm_gau_set));
strcpy(&entry->expansion[0],"Provide a filename!");
}
else
{
CopyMem(&default_gauge,entry, sizeof(struct tm_gau_set));
}
entry->type = (UWORD)active;
if(active==typ_clock_) entry->gauge_type=typ_clock;
get (obj, MUIA_List_DropMark, &dropmark);
DoMethod(obj, MUIM_List_InsertSingle, entry,dropmark);
set (obj, MUIA_List_Active, dropmark);
set (msg->obj, MUIA_List_Active, MUIV_List_Active_Off);
}
}
else
{
DoMethod(msg->obj,MUIM_List_Remove,MUIV_List_Remove_Active);
}
return(obj);
}
}
__geta4 ULONG FieldsList_Dispatcher(__a0 struct IClass *cl,__a2 Object *obj,__a1 Msg msg)
{
switch (msg->MethodID)
{
case MUIM_DragQuery: return(FieldsList_DragQuery(cl,obj,(APTR)msg));
case MUIM_DragDrop : return(FieldsList_DragDrop (cl,obj,(APTR)msg));
}
return(DoSuperMethodA(cl,obj,msg));
}
///
/******************************************/
/* ChooseFields class */
/******************************************/
///
Object *available, *visible;
struct ChooseFields_Data
{
ULONG dummy;
};
struct ComposerMsg
{
ULONG MethodID;
Object *listview;
struct ChooseFields_Data *data;
};
#define Dis_ID_DoubleClickComposer 1
#define Dis_ID_ComposerClose 2
#define Dis_ID_ComposerSave 3
#define Dis_ID_LauncherClose 4
#define Dis_ID_LauncherSave 5
#define Dis_ID_CloneEntry 6
#define Originator ( TAG_USER + 1 )
#define Gauge_Settings ( TAG_USER + 2 )
static ULONG DoubleClickComposer(struct IClass *cl,Object *obj, struct ComposerMsg *msg)
{
struct tm_gau_set *desc;
Object *tmp;
DoMethod(msg->listview,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&desc);
if (desc)
{
set((Object *)xget(obj,MUIA_ApplicationObject),MUIA_Application_Sleep,TRUE);
switch (desc->type)
{
case typ_none:
break;
case typ_iconlauncher:
case typ_simplelauncher:
if (tmp = (APTR)NewObject(CL_Launcher->mcc_Class,NULL,
Originator, obj,
Gauge_Settings, desc,
TAG_DONE))
{
DoMethod((Object *)xget(obj,MUIA_ApplicationObject),OM_ADDMEMBER,tmp);
set(tmp,MUIA_Window_Open,TRUE);
}
break;
default:
if (tmp = (APTR)NewObject(CL_Composer->mcc_Class,NULL,
Originator, obj,
Gauge_Settings, desc,
TAG_DONE))
{
DoMethod((Object *)xget(obj,MUIA_ApplicationObject),OM_ADDMEMBER,tmp);
set(tmp,MUIA_Window_Open,TRUE);
}
else DisplayBeep(0);
break;
}
set((Object *)xget(obj,MUIA_ApplicationObject),MUIA_Application_Sleep,FALSE);
}
return((ULONG)0);
}
static ULONG Clone_Entry(struct IClass *cl,Object *obj, struct ComposerMsg *msg)
{
struct tm_gau_set *desc,*news;
DoMethod(msg->listview,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&desc);
if (desc)
{
if(news=AllocVec(sizeof(struct tm_gau_set),0L))
{
CopyMem(desc,news,sizeof(struct tm_gau_set));
DoMethod(msg->listview,MUIM_List_InsertSingle,news,MUIV_List_Insert_Active);
}
}
}
static ULONG ChooseFields_New(struct IClass *cl,Object *obj,struct opSet *msg)
{
Object *BT_Clone;
obj = (Object *)DoSuperNew(cl,obj,
MUIA_Group_Columns, 2,
MUIA_Group_VertSpacing, 1,
Child, TextObject, MUIA_Text_Contents, GetStr(MDL_Available), End,
Child, TextObject, MUIA_Text_Contents, GetStr(MDL_Selected ), End,
Child, ListviewObject,
MUIA_Listview_DragType, 1,
MUIA_Listview_List, available = NewObject(CL_FieldsList->mcc_Class,NULL,
InputListFrame,
MUIA_List_SourceArray , gau_types,
MUIA_List_ShowDropMarks, FALSE,
TAG_DONE),
End,
Child,VGroup,
Child, ListviewObject,
MUIA_Listview_DragType, 1,
MUIA_Listview_DoubleClick, TRUE,
MUIA_Listview_List, visible = NewObject(CL_FieldsList->mcc_Class,NULL,
InputListFrame,
MUIA_List_ConstructHook, &gau_ConstructHook,
MUIA_List_DestructHook , &gau_DestructHook,
MUIA_List_DisplayHook , &gau_DisplayHook,
MUIA_List_Format , "MIW=50 MAW=100 BAR,",
MUIA_List_DragSortable , TRUE,
TAG_DONE),
End,
Child, BT_Clone=SimpleButton(GetStr(MCO_Clone)),
End,
End;
if (obj)
{
DoMethod(visible, MUIM_Notify,MUIA_Listview_DoubleClick,TRUE,obj,2,Dis_ID_DoubleClickComposer,visible);
DoMethod(BT_Clone,MUIM_Notify,MUIA_Pressed,TRUE, obj,2,Dis_ID_CloneEntry ,visible);
set(available,MUIA_UserData,visible);
set(visible,MUIA_UserData,available);
set(available,MUIA_ShortHelp,GetStr(MDH_Available));
set(visible,MUIA_ShortHelp,GetStr(MDH_Selected));
}
return((ULONG)obj);
}
ULONG Composer_Close(struct IClass *cl, Object *obj, struct ComposerFinishMsg *msg);
ULONG Launcher_Close(struct IClass *cl, Object *obj, struct LauncherFinishMsg *msg);
static __saveds __asm ULONG ChooseFields_Dispatcher(__a0 struct IClass *cl,__a2 Object *obj,__a1 Msg msg)
{
switch (msg->MethodID)
{
case OM_NEW : return(ChooseFields_New (cl,obj,(APTR)msg));
case Dis_ID_DoubleClickComposer : return(DoubleClickComposer (cl,obj,(APTR)msg));
case Dis_ID_ComposerClose : return(Composer_Close (cl,obj,(APTR)msg));
case Dis_ID_LauncherClose : return(Launcher_Close (cl,obj,(APTR)msg));
case Dis_ID_CloneEntry : return(Clone_Entry (cl,obj,(APTR)msg));
}
return(DoSuperMethodA(cl,obj,msg));
}
///
/*************************************************/
/* Composer Class */
/*************************************************/
/******************************************/
/* Composer Menu */
/******************************************/
///
struct NewMenu CmpMenuData[] =
{
{ NM_TITLE, (STRPTR)MCM_Gauge , 0 ,0 ,0 ,(APTR)CMP_PROJECT },
{ NM_ITEM , (STRPTR)MCM_Open ,"O",0 ,0 ,(APTR)CMP_LOAD },
{ NM_ITEM , (STRPTR)MCM_SaveAs ,"S",0 ,0 ,(APTR)CMP_SAVE },
{ NM_ITEM , NM_BARLABEL , 0 ,0 ,0 ,(APTR)0 },
{ NM_ITEM , (STRPTR)MCM_Cancel ,"C",0 ,0 ,(APTR)CMP_CANCEL },
{ NM_END,NULL,0,0,0,(APTR)0 }
};
///
/******************************************/
/* Composer class */
/******************************************/
///
#define Dis_ID_DoubleClickDevice 8
#define Dis_ID_SaveGauge 9
#define Dis_ID_LoadGauge 10
#define Dis_ID_ShowFormatHelp 11
struct Composer_Data
{
Object *ST_Label,
*PO_Device,
*ST_Device,
*CY_Type,
*NB_Height,
*CS_Colors[16],
*ST_Font,
*ST_Format,
*CM_3D,
*CM_Border,
*CM_Bg,
*CM_Shadow,
*CM_NoGauge,
*CM_NoFmt,
*CM_NoBase,
*CY_Indent,
*LV_Device,
*VL_Device,
*originator,
*sub_win,
*BT_Use,
*BT_Cancel,
*PO_Device,
*CMP_Menu,
*BT_Quest;
struct tm_gau_set *gauge;
};
static ULONG DoubleClickDev(struct IClass *cl,Object *obj, struct DoubleClkMsg *msg)
{
char *my_ptr;
struct Composer_Data *data = INST_DATA(cl,obj);
DoMethod(data->VL_Device,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&my_ptr);
if(my_ptr)
{
set(data->ST_Device,MUIA_String_Contents,my_ptr);
DoMethod(data->PO_Device,MUIM_Popstring_Close,0L);
return(DoSuperMethodA(cl,obj,msg));
}
else return(0L);
}
struct ComposerFinishMsg
{
ULONG MethodID;
Object *win;
ULONG ok;
};
ULONG Composer_Close(struct IClass *cl, Object *obj, struct ComposerFinishMsg *msg)
{
if(msg->ok)
{
DoMethod(msg->win,Dis_ID_ComposerSave,msg->win,TRUE);
}
set(msg->win,MUIA_Window_Open,FALSE);
DoMethod((Object *)xget(obj,MUIA_ApplicationObject),OM_REMMEMBER,msg->win);
MUI_DisposeObject(msg->win);
return((ULONG)0L);
}
ULONG Composer_Save(struct IClass *cl, Object *obj, struct ComposerFinishMsg *msg)
{
int i;
ULONG dummy;
struct Composer_Data *data = INST_DATA(cl,obj);
for(i=0;i<8;i++) getColor(&data->gauge->Colors[i],data->CS_Colors[i]);
get(data->ST_Label ,MUIA_String_Contents,&dummy); strcpy(&data->gauge->label[0] , dummy ? (char *)dummy : " " );
get(data->ST_Device ,MUIA_String_Contents,&dummy); strcpy(&data->gauge->expansion[0], dummy ? (char *)dummy : " " );
get(data->CY_Type ,MUIA_Cycle_Active ,&dummy); data->gauge->gauge_type =(UWORD)dummy;
get(data->NB_Height ,MUIA_Numeric_Value ,&dummy); data->gauge->size_y =(UWORD)dummy-100;
get(data->CM_3D ,MUIA_Selected ,&dummy); data->gauge->sty_3d =(UWORD)dummy;
get(data->CM_Border ,MUIA_Selected ,&dummy); data->gauge->sty_border =(UWORD)dummy;
get(data->CM_Bg ,MUIA_Selected ,&dummy); data->gauge->sty_bg =(UWORD)dummy;
get(data->CM_Shadow ,MUIA_Selected ,&dummy); data->gauge->sty_shadow =(UWORD)dummy;
get(data->CM_NoGauge,MUIA_Selected ,&dummy); data->gauge->sty_nogauge =(UWORD)dummy;
get(data->CM_NoFmt ,MUIA_Selected ,&dummy); data->gauge->sty_noformat=(UWORD)dummy;
get(data->CM_NoBase ,MUIA_Selected ,&dummy); data->gauge->sty_nobase =(UWORD)dummy;
get(data->CY_Indent ,MUIA_Cycle_Active ,&dummy); data->gauge->indent =(UWORD)dummy;
get(data->ST_Font ,MUIA_String_Contents,&dummy); sscanf((char *)dummy,"%[^/]/%d",&data->gauge->font[0],&i);
strcat(&data->gauge->font[0],".font"); data->gauge->font_size=(WORD)i;
get(data->ST_Format ,MUIA_String_Contents,&dummy); strcpy((char *)&data->gauge->format[0], dummy ? (char *)dummy : " " );
DoMethod(visible,MUIM_List_Redraw,MUIV_List_Redraw_All);
}
char *types[] ={(STRPTR)MCL_Normal,(STRPTR)MCL_Historymeter,0L};
char *indent[] ={(STRPTR)MCL_center,(STRPTR)MCL_left,(STRPTR)MCL_right,0L};
char *regcomposer[] ={(STRPTR)MCR_general,(STRPTR)MCR_flags,(STRPTR)MCR_colors,0L};
insertComposerSettings(struct tm_gau_set *gauge, struct Composer_Data *data)
{
int i;
char dummy[256];
for(i=0;i<8;i++)
{
initColor(&gauge->Colors[i],data->CS_Colors[i]);
if(gauge->type == typ_clock_) set(data->CS_Colors[i],MUIA_Disabled,TRUE);
}
set(data->NB_Height,MUIA_Numeric_Value,gauge->size_y+100);
if(gauge->type != typ_volume) set(data->PO_Device, MUIA_Disabled,TRUE);
if((gauge->gauge_type==typ_histmeter)||(gauge->type==typ_clock_))
{
set(data->ST_Label, MUIA_Disabled,TRUE);
set(data->CM_3D, MUIA_Disabled,TRUE);
set(data->CM_Shadow, MUIA_Disabled,TRUE);
if(gauge->type==typ_clock_)
{
set(data->CM_Bg, MUIA_Disabled,TRUE);
set(data->CS_Colors[col_format] ,MUIA_Disabled,FALSE);
set(data->CS_Colors[col_dark] ,MUIA_Disabled,FALSE);
set(data->CM_Shadow ,MUIA_Disabled,FALSE);
set(data->CM_Border ,MUIA_Disabled,TRUE);
set(data->CM_NoGauge ,MUIA_Disabled,TRUE);
set(data->CM_NoFmt ,MUIA_Disabled,TRUE);
set(data->CM_NoBase ,MUIA_Disabled,TRUE);
set(data->CY_Type ,MUIA_Disabled,TRUE);
}
}
set(data->CM_3D ,MUIA_Selected,gauge->sty_3d);
set(data->CM_Border ,MUIA_Selected,gauge->sty_border);
set(data->CM_Bg ,MUIA_Selected,gauge->sty_bg);
set(data->CM_Shadow ,MUIA_Selected,gauge->sty_shadow);
set(data->CM_NoGauge,MUIA_Selected,gauge->sty_nogauge);
set(data->CM_NoFmt ,MUIA_Selected,gauge->sty_noformat);
set(data->CM_NoBase ,MUIA_Selected,gauge->sty_nobase);
set(data->ST_Format ,MUIA_String_Contents,&gauge->format[0]);
strcpy(&dummy[0],gauge->font);
sprintf((char *)&dummy[strlen(&dummy[0])-5],"/%d",gauge->font_size);
set(data->ST_Font ,MUIA_String_Contents,&dummy[0]);
set(data->ST_Device ,MUIA_String_Contents,&gauge->expansion[0]);
set(data->ST_Label ,MUIA_String_Contents,&gauge->label[0]);
set(data->CY_Indent ,MUIA_Cycle_Active,gauge->indent);
set(data->CY_Type ,MUIA_Cycle_Active,gauge->gauge_type);
}
LoadGaugeSet(struct IClass *cl,Object *obj)
{
struct Composer_Data *data=INST_DATA(cl,obj);
char *file;
ULONG my_file;
ULONG buf;
UWORD old_type;
char old_expansion[128];
if(file=getfilename(obj,GetStr(MCM_LoadGauge),"#?.tmgauge",FALSE))
{
if(my_file=(ULONG)Open(file,MODE_OLDFILE))
{
Read(my_file,&buf,4L);
if(buf==0x544D4731)
{
old_type=data->gauge->type;
CopyMem(&data->gauge->expansion[0],&old_expansion[0],128L);
Read(my_file,data->gauge,sizeof(struct tm_gau_set));
data->gauge->type=old_type;
CopyMem(&old_expansion[0],&data->gauge->expansion[0],128L);
insertComposerSettings(data->gauge,data);
}
else MUI_RequestA((Object *)xget(obj,MUIA_ApplicationObject),obj,0,"TinyMeterPrefs",GetStr(MCM_NotTmGauge_fmt),GetStr(MCM_NotTmGauge),NULL);
Close(my_file);
}
}
}
SaveGaugeSet(struct IClass *cl,Object *obj)
{
struct Composer_Data *data=INST_DATA(cl,obj);
char *file;
ULONG buf,my_file;
struct ComposerFinishMsg msg;
msg.ok=TRUE;
Composer_Save( cl,obj,&msg);
buf=0x544D4731;
if(file=getfilename(obj,GetStr(MCM_SaveGauge),"#?.tmgauge",TRUE))
{
if(my_file=Open(file,MODE_NEWFILE))
{
Write(my_file,&buf,4L);
Write(my_file,data->gauge,sizeof(struct tm_gau_set));
Close(my_file);
}
}
}
Object *WI_HelpFmt,
*WI_HelpClock;
static ULONG Composer_New(struct IClass *cl,Object *obj,struct opSet *msg)
{
struct Composer_Data *data,*new_data;
if(new_data=AllocVec(sizeof(struct Composer_Data),0L))
{
if(new_data->gauge = (struct tm_gau_set *)GetTagData(Gauge_Settings,0,msg->ops_AttrList))
{
if( obj = (Object *)DoSuperNew(cl,obj,
MUIA_Window_Title , gau_types[new_data->gauge->type] ,
MUIA_Window_ID , MAKE_ID('T','M','C','O'),
MUIA_Window_Menustrip , new_data->CMP_Menu = MUI_MakeObject(MUIO_MenustripNM,CmpMenuData,0),
WindowContents, VGroup, ButtonFrame,
Child, HGroup,
Child, VGroup, MUIA_Background, MUII_SHADOW,
Child, VSpace(0),
Child, BodychunkObject,
MUIA_FixWidth , HEADER_LOGO_WIDTH ,
MUIA_FixHeight , HEADER_LOGO_HEIGHT,
MUIA_Bitmap_Width , HEADER_LOGO_WIDTH ,
MUIA_Bitmap_Height , HEADER_LOGO_HEIGHT,
MUIA_Bodychunk_Depth , HEADER_LOGO_DEPTH ,
MUIA_Bodychunk_Body , (UBYTE *)header_logo_body,
MUIA_Bodychunk_Compression, HEADER_LOGO_COMPRESSION,
MUIA_Bodychunk_Masking , HEADER_LOGO_MASKING,
MUIA_Bitmap_SourceColors , (ULONG *)header_logo_colors,
MUIA_Bitmap_Transparent , 0,
End,
End,
Child, RegisterGroup(regcomposer),
MUIA_Register_Frame, TRUE,
Child, ColGroup(2),
Child, VSpace(0),
Child, VSpace(0),
Child, Label(GetStr(MCO_type)),
Child, new_data->CY_Type=CycleObject,
MUIA_Cycle_Entries, types,
End,
Child, Label(GetStr(MCO_label)),
Child, new_data->ST_Label=String(0L,16),
Child, Label(GetStr(MCO_height)),
Child, ColGroup(2), Child, new_data->NB_Height=MUI_MakeObject(MUIO_NumericButton,NULL,100,1000,GetStr(MCO_height_fmt)), Child, HVSpace, End,
Child, Label(GetStr(MCO_font)),
Child, PopaslObject,
MUIA_Popstring_String, new_data->ST_Font=(Object *)String(0L,80),
MUIA_Popstring_Button, PopButton(MUII_PopUp),
MUIA_Popasl_Type , ASL_FontRequest,
ASLFO_TitleText , GetStr(MCO_sel_font),
End,
Child, Label(GetStr(MCO_device)),
Child, new_data->PO_Device=PopobjectObject,
MUIA_Popstring_String, new_data->ST_Device=String(0L,128),
MUIA_Popstring_Button, PopButton(MUII_PopUp),
MUIA_Popobject_Object, new_data->LV_Device=ListviewObject,
MUIA_Weight, 20,
MUIA_Listview_Input, TRUE,
MUIA_Listview_DoubleClick, TRUE,
MUIA_Listview_List, new_data->VL_Device=VolumelistObject,
InputListFrame,
MUIA_Dirlist_Directory, "ram:",
End,
End,
End,
Child, VSpace(0),
Child, VSpace(0),
End,
Child, ColGroup(2),
Child, VSpace(0),
Child, VSpace(0),
Child, Label(GetStr(MCO_3dlook)),
Child, new_data->CM_3D=CheckMark(new_data->gauge->sty_3d),
Child, Label(GetStr(MCO_border)),
Child, new_data->CM_Border=CheckMark(new_data->gauge->sty_border),
Child, Label(GetStr(MCO_nobgcol)),
Child, new_data->CM_Bg=CheckMark(new_data->gauge->sty_bg),
Child, Label(GetStr(MCO_shadow)),
Child, new_data->CM_Shadow=CheckMark(new_data->gauge->sty_shadow),
Child, Label(GetStr(MCO_disgaug)),
Child, new_data->CM_NoGauge=CheckMark(new_data->gauge->sty_nogauge),
Child, Label(GetStr(MCO_disfmt)),
Child, new_data->CM_NoFmt=CheckMark(new_data->gauge->sty_noformat),
Child, Label(GetStr(MCO_disbas)),
Child, new_data->CM_NoBase=CheckMark(new_data->gauge->sty_nobase),
Child, VSpace(0),
Child, VSpace(0),
End,
Child, ColGroup(2),
Child, ColGroup(2),
Child, VSpace(0),
Child, VSpace(0),
Child, Label(GetStr(MCO_col_label)),
Child, new_data->CS_Colors[col_label] =MakePen(),
Child, Label(GetStr(MCO_col_fmt)),
Child, new_data->CS_Colors[col_format] =MakePen(),
Child, Label(GetStr(MCO_col_bas)),
Child, new_data->CS_Colors[col_base] =MakePen(),
Child, Label(GetStr(MCO_col_cur)),
Child, new_data->CS_Colors[col_current] =MakePen(),
Child, VSpace(0),
Child, VSpace(0),
End,
Child, ColGroup(2),
Child, VSpace(0),
Child, VSpace(0),
Child, Label(GetStr(MCO_col_neg)),
Child, new_data->CS_Colors[col_negative] =MakePen(),
Child, Label(GetStr(MCO_col_bright)),
Child, new_data->CS_Colors[col_bright] =MakePen(),
Child, Label(GetStr(MCO_col_dark)),
Child, new_data->CS_Colors[col_dark] =MakePen(),
Child, Label(GetStr(MCO_col_bg)),
Child, new_data->CS_Colors[col_bg] =MakePen(),
Child, VSpace(0),
Child, VSpace(0),
End,
End,
End,
End,
Child, HGroup, GroupFrameT(GetStr(MCO_fmt)),
Child, new_data->ST_Format=(Object *)String(0L,128),
Child, new_data->BT_Quest=BodychunkObject,
ButtonFrame,
MUIA_InputMode , MUIV_InputMode_RelVerify,
MUIA_FixWidth , QUESTION_WIDTH ,
MUIA_FixHeight , QUESTION_HEIGHT,
MUIA_Bitmap_Width , QUESTION_WIDTH ,
MUIA_Bitmap_Height , QUESTION_HEIGHT,
MUIA_Bodychunk_Depth , QUESTION_DEPTH ,
MUIA_Bodychunk_Body , (UBYTE *)question_body,
MUIA_Bodychunk_Compression, QUESTION_COMPRESSION,
MUIA_Bodychunk_Masking , QUESTION_MASKING,
MUIA_Bitmap_SourceColors , (ULONG *)question_colors,
MUIA_Bitmap_Transparent , 0,
End,
Child, new_data->CY_Indent=CycleObject,
MUIA_Weight, 0,
MUIA_Cycle_Entries, indent,
End,
End,
Child, HGroup,
Child, new_data->BT_Use = (Object *)SimpleButton(GetStr(MCO_Use)),
Child, new_data->BT_Cancel = (Object *)SimpleButton(GetStr(MCO_Cancel)),
End,
End,
End)
{
data=INST_DATA(cl,obj);
CopyMem(new_data,data,sizeof(struct Composer_Data));
FreeVec(new_data);
set(data->ST_Label,MUIA_ShortHelp,GetStr(MOH_Label));
set(data->PO_Device,MUIA_ShortHelp,GetStr(MOH_Device));
set(data->CM_Border,MUIA_ShortHelp,GetStr(MOH_3d));
set(data->CM_Bg,MUIA_ShortHelp,GetStr(MOH_Bg));
set(data->CM_NoGauge,MUIA_ShortHelp,GetStr(MOH_NoGauge));
set(data->CM_NoFmt,MUIA_ShortHelp,GetStr(MOH_NoFmt));
set(data->CM_NoBase,MUIA_ShortHelp,GetStr(MOH_NoBase));
insertComposerSettings(data->gauge,data);
data->originator = (Object *)GetTagData(Originator,0,msg->ops_AttrList);
DoMethod(data->LV_Device, MUIM_Notify,MUIA_Listview_DoubleClick ,TRUE,obj,1,Dis_ID_DoubleClickDevice);
DoMethod(data->CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_gauge ,data->ST_Label,3,MUIM_Set,MUIA_Disabled,FALSE);
DoMethod(data->CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_histmeter,data->ST_Label,3,MUIM_Set,MUIA_Disabled,TRUE);
DoMethod(data->CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_gauge ,data->CM_3D,3,MUIM_Set,MUIA_Disabled,FALSE);
DoMethod(data->CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_histmeter,data->CM_3D,3,MUIM_Set,MUIA_Disabled,TRUE);
DoMethod(data->CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_gauge ,data->CM_Shadow,3,MUIM_Set,MUIA_Disabled,FALSE);
DoMethod(data->CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_histmeter,data->CM_Shadow,3,MUIM_Set,MUIA_Disabled,TRUE);
DoMethod(data->CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_gauge ,data->CM_Bg,3,MUIM_Set,MUIA_Disabled,FALSE);
DoMethod(data->CY_Type, MUIM_Notify,MUIA_Cycle_Active,typ_histmeter,data->CM_Bg,3,MUIM_Set,MUIA_Disabled,TRUE);
if(data->gauge->type!=typ_clock_) DoMethod(data->BT_Quest, MUIM_Notify,MUIA_Pressed,FALSE, WI_HelpFmt ,3,MUIM_Set,MUIA_Window_Open,TRUE);
else DoMethod(data->BT_Quest, MUIM_Notify,MUIA_Pressed,FALSE, WI_HelpClock ,3,MUIM_Set,MUIA_Window_Open,TRUE);
DoMethod(obj, MUIM_Notify,MUIA_Window_CloseRequest,TRUE, MUIV_Notify_Application,6,MUIM_Application_PushMethod,data->originator,3,Dis_ID_ComposerClose,obj,FALSE);
DoMethod(data->BT_Cancel, MUIM_Notify,MUIA_Pressed,FALSE, MUIV_Notify_Application,6,MUIM_Application_PushMethod,data->originator,3,Dis_ID_ComposerClose,obj,FALSE);
DoMethod(data->BT_Use, MUIM_Notify,MUIA_Pressed,FALSE, MUIV_Notify_Application,6,MUIM_Application_PushMethod,data->originator,3,Dis_ID_ComposerClose,obj,TRUE);
DoMethod(obj, MUIM_Notify,MUIA_Window_MenuAction,CMP_SAVE,obj,1,Dis_ID_SaveGauge);
DoMethod(obj, MUIM_Notify,MUIA_Window_MenuAction,CMP_LOAD,obj,1,Dis_ID_LoadGauge);
return((ULONG)obj);
}
}
}
return(0L);
}
static __saveds __asm ULONG ComposerDispatcher(__a0 struct IClass *cl,__a2 Object *obj,__a1 Msg msg)
{
switch (msg->MethodID)
{
case OM_NEW : return(Composer_New (cl,obj,(APTR)msg));
case Dis_ID_ComposerSave : return(Composer_Save (cl,obj,(APTR)msg));
case Dis_ID_DoubleClickDevice : return(DoubleClickDev (cl,obj,(APTR)msg));
case Dis_ID_SaveGauge : return(SaveGaugeSet (cl,obj));
case Dis_ID_LoadGauge : return(LoadGaugeSet (cl,obj));
}
return(DoSuperMethodA(cl,obj,msg));
}
///
/*************************************************/
/* Launcher Class */
/*************************************************/
/******************************************/
/* Launcher Menu */
/******************************************/
///
struct NewMenu LauMenuData[] =
{
{ NM_TITLE, (STRPTR)MCM_Gauge , 0 ,0 ,0 ,(APTR)CMP_PROJECT },
{ NM_ITEM , (STRPTR)MCM_Open ,"O",0 ,0 ,(APTR)CMP_LOAD },
{ NM_ITEM , (STRPTR)MCM_SaveAs ,"S",0 ,0 ,(APTR)CMP_SAVE },
{ NM_ITEM , NM_BARLABEL , 0 ,0 ,0 ,(APTR)0 },
{ NM_ITEM , (STRPTR)MCM_Cancel ,"C",0 ,0 ,(APTR)CMP_CANCEL },
{ NM_END,NULL,0,0,0,(APTR)0 }
};
///
/******************************************/
/* Launcher class */
/******************************************/
///
#define lind_realcenter 0
#define lind_center 1
#define lind_left 2
#define lind_right 3
#define launch_wb 0
#define launch_cli 1
#define Dis_ID_NewEntry 13
#define Dis_ID_RemoveEntry 14
#define Dis_ID_CloneEntry 15
#define Dis_ID_ChangeActive 16
#define Dis_ID_InsertActive 17
#define Dis_ID_LoadSet 19
#define Dis_ID_LoadStr 20
#define Dis_ID_SaveLauncher 21
#define Dis_ID_LoadLauncher 22
struct lau_entry
{
char lau_titl[32];
char lau_cmd[256];
UWORD lau_type;
char lau_pth[256];
char lau_out[256];
char lau_img[256];
ULONG lau_stack;
};
char *reglauncher[] ={(STRPTR)MCR_entries,(STRPTR)MCR_general,(STRPTR)MCR_colors,0L};
char *cyplace[] ={(STRPTR)MCR_up,(STRPTR)MCR_down,(STRPTR)MCR_over,0L};
char *cyindent[] ={(STRPTR)MCR_rightcenter,(STRPTR)MCR_center,(STRPTR)MCR_left,(STRPTR)MCR_right,0L};
char *lau_type[] ={"WB","CLI",0L};
__saveds __asm APTR lau_consfunc(__a1 struct lau_entry *src)
{
return(src);
}
__saveds __asm ULONG lau_desfunc(__a1 struct lau_entry *src)
{
return(FreeVec(src));
}
__saveds __asm void lau_dispfunc(__a2 char **array,__a1 struct lau_entry *src)
{
*array++ = &src->lau_titl[0];
*array++ = &src->lau_cmd[0];
*array = lau_type[src->lau_type];
}
static const struct Hook lau_ConstructHook = { { 0,0 }, (void *)lau_consfunc, NULL, NULL };
static const struct Hook lau_DestructHook = { { 0,0 }, (void *)lau_desfunc , NULL, NULL };
static const struct Hook lau_DisplayHook = { { 0,0 }, (void *)lau_dispfunc, NULL, NULL };
struct Launcher_Data
{
struct tm_gau_set *gauge;
Object *originator,
*BT_Cancel,
*BT_Use,
*CS_Colors[8],
*LAU_Menu,
*LV_Entries,
*ST_listfile,
*CM_Xen,
*CM_Bg,
*CM_Shadow,
*CM_Border,
*CM_Transparent,
*BT_New,
*BT_Remove,
*BT_Clone,
*BT_Save,
*BT_Reload,
*ST_File,
*ST_Title,
*ST_Stack,
*ST_Path,
*ST_Out,
*CY_File,
*CY_Place,
*CY_Indent,
*NB_Height,
*ST_Font,
*ST_Label,
*ST_Img,
*ST_MImg;
};
struct LauncherFinishMsg
{
ULONG MethodID;
Object *win;
ULONG ok;
};
ULONG Launcher_Close(struct IClass *cl, Object *obj, struct LauncherFinishMsg *msg)
{
if(msg->ok)
{
if(DoMethod(msg->win,Dis_ID_LauncherSave))
{
set(msg->win,MUIA_Window_Open,FALSE);
DoMethod((Object *)xget(obj,MUIA_ApplicationObject),OM_REMMEMBER,msg->win);
MUI_DisposeObject(msg->win);
}
}
else
{
set(msg->win,MUIA_Window_Open,FALSE);
DoMethod((Object *)xget(obj,MUIA_ApplicationObject),OM_REMMEMBER,msg->win);
MUI_DisposeObject(msg->win);
}
return((ULONG)0L);
}
insertLauncherSettings(struct tm_gau_set *gauge, struct Launcher_Data *data)
{
int i;
char dummy[256];
for(i=0;i<8;i++) initColor(&gauge->Colors[i],data->CS_Colors[i]);
set(data->CM_Xen ,MUIA_Selected, gauge->sty_3d);
set(data->CM_Transparent,MUIA_Selected, gauge->sty_noformat);
set(data->CM_Border ,MUIA_Selected, gauge->sty_border);
set(data->CM_Bg ,MUIA_Selected, gauge->sty_bg);
set(data->CM_Shadow ,MUIA_Selected, gauge->sty_shadow);
set(data->CY_Place ,MUIA_Cycle_Active, gauge->sty_nogauge);
set(data->CY_Indent ,MUIA_Cycle_Active, gauge->indent);
set(data->ST_listfile,MUIA_String_Contents, gauge->expansion);
set(data->NB_Height,MUIA_Numeric_Value,gauge->size_y+100);
strcpy(&dummy[0],gauge->font);
sprintf((char *)&dummy[strlen(&dummy[0])-5],"/%d",gauge->font_size);
set(data->ST_Font ,MUIA_String_Contents,&dummy[0]);
if(gauge->type==typ_iconlauncher)
{
set(data->ST_Font, MUIA_Disabled, TRUE);
set(data->NB_Height, MUIA_Disabled, TRUE);
set(data->CM_Xen, MUIA_Disabled, TRUE);
set(data->CM_Border, MUIA_Disabled, TRUE);
set(data->CM_Bg, MUIA_Disabled, TRUE);
set(data->CM_Shadow, MUIA_Disabled, TRUE);
set(data->CY_Place, MUIA_Disabled, TRUE);
set(data->ST_Label, MUIA_Disabled, TRUE);
set(data->ST_MImg, MUIA_Disabled, TRUE);
for(i=0;i<8;i++) set(data->CS_Colors[i],MUIA_Disabled,TRUE);
}
}
saveLauncherSettings(struct Launcher_Data *data)
{
int i;
ULONG dummy;
for(i=0;i<8;i++) getColor(&data->gauge->Colors[i],data->CS_Colors[i]);
get(data->CM_Xen ,MUIA_Selected ,&dummy); data->gauge->sty_3d =(UWORD)dummy;
get(data->CM_Transparent,MUIA_Selected ,&dummy); data->gauge->sty_noformat=(UWORD)dummy;
get(data->CM_Border ,MUIA_Selected ,&dummy); data->gauge->sty_border =(UWORD)dummy;
get(data->CM_Bg ,MUIA_Selected ,&dummy); data->gauge->sty_bg =(UWORD)dummy;
get(data->CM_Shadow ,MUIA_Selected ,&dummy); data->gauge->sty_shadow =(UWORD)dummy;
get(data->CY_Place ,MUIA_Cycle_Active ,&dummy); data->gauge->sty_nogauge =(UWORD)dummy;
get(data->CY_Indent ,MUIA_Cycle_Active ,&dummy); data->gauge->indent =(UWORD)dummy;
get(data->ST_listfile,MUIA_String_Contents,&dummy); strcpy((char *)&data->gauge->expansion[0], dummy ? (char *)dummy : " " );
get(data->NB_Height ,MUIA_Numeric_Value ,&dummy); data->gauge->size_y =(UWORD)dummy-100;
get(data->ST_Font ,MUIA_String_Contents,&dummy); sscanf((char *)dummy,"%[^/]/%d",&data->gauge->font[0],&i);
strcat(&data->gauge->font[0],".font"); data->gauge->font_size=(WORD)i;
DoMethod(visible,MUIM_List_Redraw,MUIV_List_Redraw_All);
}
LoadLauncherSet(struct IClass *cl,Object *obj)
{
struct Launcher_Data *data=INST_DATA(cl,obj);
char *file;
ULONG my_file;
ULONG buf;
if(file=getfilename(obj,GetStr(MCM_LoadGauge),"#?.tmgauge",FALSE))
{
if(my_file=(ULONG)Open(file,MODE_OLDFILE))
{
Read(my_file,&buf,4L);
if(buf==0x544D4732)
{
Read(my_file,data->gauge,sizeof(struct tm_gau_set));
insertLauncherSettings(data->gauge,data);
DoMethod(obj,Dis_ID_LoadSet,0L);
}
else MUI_RequestA((Object *)xget(obj,MUIA_ApplicationObject),obj,0,"TinyMeterPrefs",GetStr(MCM_NotTmGauge_fmt),GetStr(MCM_NotTmGauge),NULL);
Close(my_file);
}
}
}
SaveLauncherSet(struct IClass *cl,Object *obj)
{
struct Launcher_Data *data=INST_DATA(cl,obj);
char *file;
ULONG buf,my_file;
saveLauncherSettings( data );
buf=0x544D4732;
if(file=getfilename(obj,GetStr(MCM_SaveGauge),"#?.tmgauge",TRUE))
{
if(my_file=Open(file,MODE_NEWFILE))
{
Write(my_file,&buf,4L);
Write(my_file,data->gauge,sizeof(struct tm_gau_set));
Close(my_file);
}
}
}
struct Launcher_Message
{
ULONG MethodID;
};
static struct lau_entry lau_default=
{
"Empty",
"",
0,
"",
"",
"",
4096
};
Launcher_ChangeActive(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
{
struct lau_entry *entry;
struct Launcher_Data *data;
data=INST_DATA(cl,obj);
DoMethod(data->LV_Entries,MUIM_List_GetEntry,MUIV_List_GetEntry_Active, &entry);
if(entry)
{
set(data->ST_File, MUIA_String_Contents, entry->lau_cmd);
set(data->ST_Title, MUIA_String_Contents, entry->lau_titl);
set(data->ST_Path, MUIA_String_Contents, entry->lau_pth);
set(data->ST_Out, MUIA_String_Contents, entry->lau_out);
set(data->ST_Img, MUIA_String_Contents, entry->lau_img);
set(data->ST_Stack, MUIA_String_Integer, (ULONG)entry->lau_stack);
// This MUST be the last!
set(data->CY_File, MUIA_Cycle_Active , (ULONG)entry->lau_type);
}
}
Launcher_InsertActive(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
{
char *str,*foo,*dummy,*foobar,*klatuu;
struct lau_entry *entry;
ULONG active,stk;
struct Launcher_Data *data;
data=INST_DATA(cl,obj);
get(data->ST_File ,MUIA_String_Contents, &str);
get(data->ST_Title ,MUIA_String_Contents, &foo);
get(data->ST_Path ,MUIA_String_Contents, &dummy);
get(data->ST_Out ,MUIA_String_Contents, &foobar);
get(data->ST_Img ,MUIA_String_Contents, &klatuu);
get(data->ST_Img ,MUIA_String_Contents, &klatuu);
get(data->ST_Stack ,MUIA_String_Integer, &stk);
get(data->CY_File ,MUIA_Cycle_Active, &active);
DoMethod(data->LV_Entries,MUIM_List_GetEntry,MUIV_List_GetEntry_Active, &entry);
if(entry)
{
strcpy(entry->lau_titl,foo);
strcpy(entry->lau_cmd, str);
strcpy(entry->lau_pth, dummy);
strcpy(entry->lau_out, foobar);
strcpy(entry->lau_img, klatuu);
entry->lau_stack = stk;
entry->lau_type = (UWORD)active;
DoMethod(data->LV_Entries,MUIM_List_Redraw,MUIV_List_Redraw_Active);
}
}
__geta4 LONG AppMsgFunc(__A2 APTR obj, __A1 struct AppMessage **x)
{
struct WBArg *ap;
ULONG active;
struct lau_entry *entry;
struct AppMessage *amsg = *x;
int i;
static char buf[256];
char *b=buf;
for (ap=amsg->am_ArgList,i=0;i<amsg->am_NumArgs;i++,ap++)
{
get(obj,MUIA_List_Active,&active);
if(entry=(struct lau_entry *)AllocVec(sizeof(struct lau_entry),MEMF_CLEAR))
{
CopyMem(&lau_default,entry, sizeof(struct lau_entry));
NameFromLock(ap->wa_Lock,buf,sizeof(buf));
strcpy(entry->lau_pth, buf);
strcpy(entry->lau_titl,ap->wa_Name);
AddPart(buf,ap->wa_Name,sizeof(buf));
strcpy(entry->lau_cmd, buf);
entry->lau_type=0L;
DoMethod(obj, MUIM_List_InsertSingle, entry,active);
set (obj, MUIA_List_Active, active);
}
}
return(0);
}
static const struct Hook AppMsgHook = { { NULL,NULL },(void *)AppMsgFunc,NULL,NULL };
Launcher_NewEntry(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
{
ULONG active;
struct lau_entry *entry;
struct Launcher_Data *data;
data=INST_DATA(cl,obj);
get(data->LV_Entries,MUIA_List_Active,&active);
if(entry=(struct lau_entry *)AllocVec(sizeof(struct lau_entry),MEMF_CLEAR))
{
CopyMem(&lau_default,entry, sizeof(struct lau_entry));
DoMethod(data->LV_Entries, MUIM_List_InsertSingle, entry,active);
set (data->LV_Entries, MUIA_List_Active, active);
}
}
Launcher_RemoveEntry(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
{
struct Launcher_Data *data;
data=INST_DATA(cl,obj);
DoMethod(data->LV_Entries,MUIM_List_Remove,MUIV_List_Remove_Active);
}
Launcher_CloneEntry(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
{
struct lau_entry *desc,*news;
struct Launcher_Data *data;
data=INST_DATA(cl,obj);
DoMethod(data->LV_Entries,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&desc);
if (desc)
{
if(news=AllocVec(sizeof(struct lau_entry),0L))
{
CopyMem(desc,news,sizeof(struct lau_entry));
DoMethod(data->LV_Entries,MUIM_List_InsertSingle,news,MUIV_List_Insert_Active);
}
}
}
Launcher_CleanString(char *buffer)
{
int i;
if((i=strlen(buffer))<1)
{
buffer[0]=0x00;
}
else
{
if(buffer[i-1]==0x0a)
{
buffer[i-1]=0x00;
}
}
}
Launcher_LoadFromSettings(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
{
BPTR file;
char buffer[256];
struct Launcher_Data *data;
struct lau_entry *entry;
data=INST_DATA(cl,obj);
if(file=(BPTR)Open(&data->gauge->expansion[0],MODE_OLDFILE))
{
if(FGets(file,&buffer[0],255))
{
if(*((ULONG *)&buffer[0])==0x544D4C49)
{
if(FGets(file,&buffer[0],255))
{
Launcher_CleanString(buffer);
set(data->ST_Label,MUIA_String_Contents,&buffer[0]);
if(FGets(file,&buffer[0],255))
{
Launcher_CleanString(buffer);
set(data->ST_MImg,MUIA_String_Contents,&buffer[0]);
while(FGets(file,&buffer[0],32))
{
if(entry=(struct lau_entry *)AllocVec(sizeof(struct lau_entry),MEMF_CLEAR))
{
Launcher_CleanString(buffer);
strcpy(entry->lau_titl,buffer);
if(FGets(file,buffer,255))
{
Launcher_CleanString(buffer);
strcpy(entry->lau_cmd,buffer);
if(FGets(file,buffer,4))
{
entry->lau_type=*((UBYTE *)&buffer[0])-0x30;
if(FGets(file,buffer,255))
{
Launcher_CleanString(buffer);
strcpy(entry->lau_pth,buffer);
if(FGets(file,buffer,255))
{
Launcher_CleanString(buffer);
strcpy(entry->lau_out,buffer);
if(FGets(file,buffer,16))
{
Launcher_CleanString(buffer);
sscanf(buffer,"%ld",&entry->lau_stack);
if(FGets(file,buffer,255))
{
Launcher_CleanString(buffer);
strcpy(entry->lau_img,buffer);
}
else strcpy(entry->lau_out,"");
}
else entry->lau_stack=0;
}
else strcpy(entry->lau_out," ");
}
else strcpy(entry->lau_pth," ");
}
else entry->lau_type=0;
}
else strcpy(entry->lau_titl,"Empty");
DoMethod(data->LV_Entries, MUIM_List_InsertSingle, entry,MUIV_List_Insert_Bottom);
}
}
}
}
}
}
Close(file);
}
}
Launcher_LoadFromString(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
{
BPTR file;
char *filename;
char buffer[256];
struct Launcher_Data *data;
struct lau_entry *entry;
data=INST_DATA(cl,obj);;
get(data->ST_listfile,MUIA_String_Contents,&filename);
if(filename)
{
if(file=(BPTR)Open(filename,MODE_OLDFILE))
{
DoMethod(data->LV_Entries,MUIM_List_Clear,0L);
if(FGets(file,&buffer[0],255))
{
if(*((ULONG *)&buffer[0])==0x544D4C49)
{
if(FGets(file,&buffer[0],255))
{
Launcher_CleanString(buffer);
set(data->ST_Label,MUIA_String_Contents,&buffer[0]);
if(FGets(file,&buffer[0],255))
{
Launcher_CleanString(buffer);
set(data->ST_MImg,MUIA_String_Contents,&buffer[0]);
while(FGets(file,&buffer[0],32))
{
if(entry=(struct lau_entry *)AllocVec(sizeof(struct lau_entry),MEMF_CLEAR))
{
Launcher_CleanString(buffer);
strcpy(entry->lau_titl,buffer);
if(FGets(file,buffer,255))
{
Launcher_CleanString(buffer);
strcpy(entry->lau_cmd,buffer);
if(FGets(file,buffer,4))
{
entry->lau_type=*((UBYTE *)&buffer[0])-0x30;
if(FGets(file,buffer,255))
{
Launcher_CleanString(buffer);
strcpy(entry->lau_pth,buffer);
if(FGets(file,buffer,255))
{
Launcher_CleanString(buffer);
strcpy(entry->lau_out,buffer);
if(FGets(file,buffer,16))
{
Launcher_CleanString(buffer);
sscanf(buffer,"%ld",&entry->lau_stack);
if(FGets(file,buffer,255))
{
Launcher_CleanString(buffer);
strcpy(entry->lau_img,buffer);
}
else strcpy(entry->lau_out,"");
}
else entry->lau_stack=0;
}
else strcpy(entry->lau_out,"");
}
else strcpy(entry->lau_pth,"");
}
else entry->lau_type=0;
}
else strcpy(entry->lau_titl,"Empty");
DoMethod(data->LV_Entries, MUIM_List_InsertSingle, entry,MUIV_List_Insert_Bottom);
}
}
}
}
}
}
Close(file);
}
}
}
ULONG Launcher_Save(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
{
int i;
struct lau_entry *entry;
char *filename,
*label,
buffer[256];
BPTR file;
struct Launcher_Data *data;
data=INST_DATA(cl,obj);
get(data->ST_listfile,MUIA_String_Contents,&filename);
if(filename&&filename[0])
{
if(strcmp(filename,"Provide a filename!")!=0)
{
if(file=(BPTR)Open(filename,MODE_NEWFILE))
{
FPuts(file,"TMLI\n");
get(data->ST_Label,MUIA_String_Contents,&label);
FPuts(file,label);
FPutC(file,0x0a);
get(data->ST_MImg,MUIA_String_Contents,&label);
FPuts(file,label);
FPutC(file,0x0a);
for (i=0;;i++)
{
DoMethod(data->LV_Entries,MUIM_List_GetEntry,i,&entry);
if (!entry) break;
FPuts(file,entry->lau_titl);
FPutC(file,0x0a);
FPuts(file,entry->lau_cmd);
FPutC(file,0x0a);
FPutC(file,entry->lau_type+0x30);
FPutC(file,0x0a);
FPuts(file,entry->lau_pth);
FPutC(file,0x0a);
FPuts(file,entry->lau_out);
FPutC(file,0x0a);
sprintf(&buffer[0],"%0ld",entry->lau_stack);
FPuts(file,&buffer[0]);
FPutC(file,0x0a);
FPuts(file,entry->lau_img);
FPutC(file,0x0a);
}
Close(file);
saveLauncherSettings(data);
return(TRUE);
}
}
}
MUI_RequestA((Object *)xget(obj,MUIA_ApplicationObject),obj,0,"TinyMeterPrefs",GetStr(MOL_nofilename_fmt),GetStr(MOL_nofilename),NULL);
return(FALSE);
}
static ULONG Launcher_New(struct IClass *cl,Object *obj,struct opSet *msg)
{
struct Launcher_Data *data,*new_data;
if(new_data=AllocVec(sizeof(struct Launcher_Data),0L))
{
if(new_data->gauge = (struct tm_gau_set *)GetTagData(Gauge_Settings,0,msg->ops_AttrList))
{
if( obj = (Object *)DoSuperNew(cl,obj,
MUIA_Window_Title , gau_types[new_data->gauge->type] ,
MUIA_Window_ID , MAKE_ID('T','M','L','A'),
MUIA_Window_Menustrip , new_data->LAU_Menu = MUI_MakeObject(MUIO_MenustripNM,LauMenuData,0),
MUIA_Window_AppWindow , TRUE,
WindowContents, VGroup, ButtonFrame,
Child, HGroup,
Child, VGroup, MUIA_Background, MUII_SHADOW,
Child, VSpace(0),
Child, BodychunkObject,
MUIA_FixWidth , HEADER_LOGO_WIDTH ,
MUIA_FixHeight , HEADER_LOGO_HEIGHT,
MUIA_Bitmap_Width , HEADER_LOGO_WIDTH ,
MUIA_Bitmap_Height , HEADER_LOGO_HEIGHT,
MUIA_Bodychunk_Depth , HEADER_LOGO_DEPTH ,
MUIA_Bodychunk_Body , (UBYTE *)header_logo_body,
MUIA_Bodychunk_Compression, HEADER_LOGO_COMPRESSION,
MUIA_Bodychunk_Masking , HEADER_LOGO_MASKING,
MUIA_Bitmap_SourceColors , (ULONG *)header_logo_colors,
MUIA_Bitmap_Transparent , 0,
End,
End,
Child, RegisterGroup(reglauncher),
MUIA_Register_Frame, TRUE,
Child, VGroup,
Child, VGroup,
Child, new_data->LV_Entries=(Object *)ListviewObject,
MUIA_Listview_Input, TRUE,
MUIA_Listview_DragType, 1,
MUIA_Dropable, FALSE,
MUIA_Listview_List, ListObject,
MUIA_Frame, MUIV_Frame_InputList,
MUIA_List_DragSortable, TRUE,
MUIA_List_ConstructHook, &lau_ConstructHook,
MUIA_List_DestructHook , &lau_DestructHook,
MUIA_List_DisplayHook , &lau_DisplayHook,
MUIA_List_Format , "BAR,MIW=5 MAW=100 BAR,",
MUIA_List_Active, MUIV_List_Active_Top,
End,
End,
Child, HGroup,
Child, Label(GetStr(MLO_Command)),
Child, new_data->ST_File=PopaslObject,
MUIA_Popstring_String, String(NULL,255),
MUIA_Popstring_Button, PopButton(MUII_PopFile),
ASLFO_TitleText , GetStr(MLO_sel_listfile),
End,
Child, new_data->CY_File=CycleObject,
MUIA_Cycle_Entries, &lau_type[0],
MUIA_Weight, 0,
End,
End,
Child, ColGroup(4),
Child, Label(GetStr(MLO_Title)),
Child, new_data->ST_Title=String(0,32),
Child, Label(GetStr(MLO_Pic)),
Child, new_data->ST_Img=PopaslObject,
MUIA_Popstring_String, String(NULL,255),
MUIA_Popstring_Button, PopButton(MUII_PopFile),
ASLFO_TitleText , GetStr(MLO_sel_listfile),
End,
Child, Label(GetStr(MLO_WorkDir)),
Child, new_data->ST_Path=PopaslObject,
MUIA_Popstring_String, String(NULL,255),
MUIA_Popstring_Button, PopButton(MUII_PopFile),
ASLFO_TitleText , GetStr(MLO_sel_listfile),
End,
Child, Label(GetStr(MLO_OutPut)),
Child, new_data->ST_Out=String(NULL,32),
Child, Label(GetStr(MLO_Stack)),
Child, new_data->ST_Stack=StringObject,
StringFrame,
MUIA_String_Accept, "0123456789",
MUIA_String_MaxLen, 32,
MUIA_String_Contents, NULL,
End,
Child, HVSpace,
Child, HVSpace,
End,
Child, ColGroup(3),
Child, new_data->BT_New=SimpleButton(GetStr(MLO_New)),
Child, new_data->BT_Remove=SimpleButton(GetStr(MLO_Remove)),
Child, new_data->BT_Clone=SimpleButton(GetStr(MLO_Clone)),
End,
End,
End,
Child, VGroup,
MUIA_Group_SameWidth,FALSE,
Child, ColGroup(2),
Child, Label(GetStr(MCO_xen)),
Child, HGroup, Child, new_data->CM_Xen=CheckMark(new_data->gauge->sty_3d), Child, HVSpace, End,
Child, Label(GetStr(MCO_transparent)),
Child, HGroup, Child, new_data->CM_Transparent=CheckMark(new_data->gauge->sty_noformat), Child, HVSpace, End,
Child, Label(GetStr(MCO_slabel)),
Child, HGroup, Child, new_data->CM_Shadow=CheckMark(new_data->gauge->sty_shadow), Child, HVSpace, End,
Child, Label(GetStr(MCO_background)),
Child, HGroup, Child, new_data->CM_Bg=CheckMark(new_data->gauge->sty_bg), Child, HVSpace, End,
Child, Label(GetStr(MCO_border)),
Child, HGroup, Child, new_data->CM_Border=CheckMark(new_data->gauge->sty_border), Child, HVSpace, End,
Child, Label(GetStr(MCO_place)),
Child, HGroup, Child, new_data->CY_Place=CycleObject,
MUIA_Cycle_Entries, &cyplace[0],
End, Child, HVSpace, End,
Child, Label(GetStr(MCR_poslabel)),
Child, HGroup, Child, new_data->CY_Indent=CycleObject,
MUIA_Cycle_Entries, &cyindent[0],
End, Child, HVSpace, End,
Child, Label(GetStr(MCO_height)),
Child, ColGroup(2), Child, new_data->NB_Height=MUI_MakeObject(MUIO_NumericButton,NULL,100,1000,GetStr(MCO_height_fmt)), Child, HVSpace, End,
Child, Label(GetStr(MCO_font)),
Child, PopaslObject,
MUIA_Popstring_String, new_data->ST_Font=(Object *)String(0L,80),
MUIA_Popstring_Button, PopButton(MUII_PopUp),
MUIA_Popasl_Type , ASL_FontRequest,
ASLFO_TitleText , GetStr(MCO_sel_font),
End,
End,
End,
Child, ColGroup(2),
Child, ColGroup(2),
Child, VSpace(0),
Child, VSpace(0),
Child, Label(GetStr(MCO_col_label)),
Child, new_data->CS_Colors[col_label] =MakePen(),
Child, Label(GetStr(MCO_col_entry)),
Child, new_data->CS_Colors[col_format] =MakePen(),
Child, Label(GetStr(MCO_col_hbright)),
Child, new_data->CS_Colors[col_base] =MakePen(),
Child, Label(GetStr(MCO_col_hdark)),
Child, new_data->CS_Colors[col_current] =MakePen(),
Child, VSpace(0),
Child, VSpace(0),
End,
Child, ColGroup(2),
Child, VSpace(0),
Child, VSpace(0),
Child, Label(GetStr(MCO_col_cursor)),
Child, new_data->CS_Colors[col_negative] =MakePen(),
Child, Label(GetStr(MCO_col_bright)),
Child, new_data->CS_Colors[col_bright] =MakePen(),
Child, Label(GetStr(MCO_col_dark)),
Child, new_data->CS_Colors[col_dark] =MakePen(),
Child, Label(GetStr(MCO_col_bg)),
Child, new_data->CS_Colors[col_bg] =MakePen(),
Child, VSpace(0),
Child, VSpace(0),
End,
End,
End,
End,
Child, VGroup,
Child, ColGroup(2), GroupFrame,
Child, Label(GetStr(MCO_label)),
Child, ColGroup(3),
Child, new_data->ST_Label=String(0L,16),
Child, Label(GetStr(MLO_Pic)),
Child, new_data->ST_MImg=PopaslObject,
MUIA_Popstring_String, String(NULL,255),
MUIA_Popstring_Button, PopButton(MUII_PopFile),
ASLFO_TitleText , GetStr(MLO_sel_picfile),
End,
End,
Child, Label(GetStr(MLO_listfile)),
Child, HGroup,
Child, new_data->ST_listfile=PopaslObject,
MUIA_Popstring_String, String(NULL,255),
MUIA_Popstring_Button, PopButton(MUII_PopFile),
ASLFO_TitleText , GetStr(MLO_sel_listfile),
End,
Child, new_data->BT_Reload=TextObject,
ButtonFrame,
MUIA_Text_Contents, GetStr(MLO_Load),
MUIA_Text_PreParse, "\33c",
MUIA_InputMode , MUIV_InputMode_RelVerify,
MUIA_Background , MUII_ButtonBack,
MUIA_Weight, 0,
End,
End,
End,
Child, HGroup,
Child, new_data->BT_Save = (Object *)SimpleButton(GetStr(MLO_Save)),
Child, new_data->BT_Cancel = (Object *)SimpleButton(GetStr(MCO_Cancel)),
End,
End,
End,
End)
{
data=INST_DATA(cl,obj);
set(data->ST_Stack,MUIA_ShortHelp,GetStr(MOL_Stack));
set(data->ST_Out,MUIA_ShortHelp,GetStr(MOL_Out));
set(data->ST_listfile,MUIA_ShortHelp,GetStr(MOL_listfile));
CopyMem(new_data,data,sizeof(struct Launcher_Data));
FreeVec(new_data);
data->originator = (Object *)GetTagData(Originator,0,msg->ops_AttrList);
insertLauncherSettings(data->gauge,data);
DoMethod(obj,Dis_ID_LoadSet,0L);
DoMethod(obj, MUIM_Notify,MUIA_Window_CloseRequest,TRUE, MUIV_Notify_Application,6,MUIM_Application_PushMethod,data->originator,4,Dis_ID_LauncherClose,obj,FALSE,data->ST_listfile);
DoMethod(data->BT_Cancel, MUIM_Notify,MUIA_Pressed,FALSE, MUIV_Notify_Application,6,MUIM_Application_PushMethod,data->originator,4,Dis_ID_LauncherClose,obj,FALSE,data->ST_listfile);
DoMethod(data->BT_Save, MUIM_Notify,MUIA_Pressed,FALSE, MUIV_Notify_Application,6,MUIM_Application_PushMethod,data->originator,4,Dis_ID_LauncherClose,obj,TRUE, data->ST_listfile);
DoMethod(data->BT_New, MUIM_Notify,MUIA_Pressed,FALSE, obj,1,Dis_ID_NewEntry);
DoMethod(data->BT_Remove, MUIM_Notify,MUIA_Pressed,FALSE, obj,1,Dis_ID_RemoveEntry);
DoMethod(data->BT_Clone, MUIM_Notify,MUIA_Pressed,FALSE, obj,1,Dis_ID_CloneEntry);
DoMethod(data->BT_Reload, MUIM_Notify,MUIA_Pressed,FALSE, obj,1,Dis_ID_LoadStr);
DoMethod(data->LV_Entries,MUIM_Notify,MUIA_List_Active,MUIV_EveryTime, obj,1,Dis_ID_ChangeActive);
DoMethod(data->ST_File, MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime, obj,1,Dis_ID_InsertActive);
DoMethod(data->ST_Title, MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime, obj,1,Dis_ID_InsertActive);
DoMethod(data->ST_Stack, MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime, obj,1,Dis_ID_InsertActive);
DoMethod(data->ST_Path, MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime, obj,1,Dis_ID_InsertActive);
DoMethod(data->ST_Img, MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime, obj,1,Dis_ID_InsertActive);
DoMethod(data->CY_File, MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime, obj,1,Dis_ID_InsertActive);
DoMethod(data->LV_Entries,MUIM_Notify,MUIA_AppMessage,MUIV_EveryTime,data->LV_Entries,3,MUIM_CallHook,&AppMsgHook,MUIV_TriggerValue);
set(data->ST_Out,MUIA_Disabled,TRUE);
DoMethod(data->CY_File, MUIM_Notify,MUIA_Cycle_Active,0,data->ST_Out,3,MUIM_Set,MUIA_Disabled,TRUE);
DoMethod(data->CY_File, MUIM_Notify,MUIA_Cycle_Active,1,data->ST_Out,3,MUIM_Set,MUIA_Disabled,FALSE);
DoMethod(obj, MUIM_Notify,MUIA_Window_MenuAction,CMP_SAVE,obj,1,Dis_ID_SaveLauncher);
DoMethod(obj, MUIM_Notify,MUIA_Window_MenuAction,CMP_LOAD,obj,1,Dis_ID_LoadLauncher);
return((ULONG)obj);
}
}
}
return(0L);
}
static __saveds __asm ULONG LauncherDispatcher(__a0 struct IClass *cl,__a2 Object *obj,__a1 Msg msg)
{
switch (msg->MethodID)
{
case OM_NEW : return(Launcher_New(cl,obj,(APTR)msg));
case Dis_ID_NewEntry : return(Launcher_NewEntry(cl,obj,(APTR)msg));
case Dis_ID_RemoveEntry : return(Launcher_RemoveEntry(cl,obj,(APTR)msg));
case Dis_ID_CloneEntry : return(Launcher_CloneEntry(cl,obj,(APTR)msg));
case Dis_ID_ChangeActive : return(Launcher_ChangeActive(cl,obj,(APTR)msg));
case Dis_ID_InsertActive : return(Launcher_InsertActive(cl,obj,(APTR)msg));
case Dis_ID_LauncherSave : return(Launcher_Save(cl,obj,(APTR)msg));
case Dis_ID_LoadStr : return(Launcher_LoadFromString(cl,obj,(APTR)msg));
case Dis_ID_LoadSet : return(Launcher_LoadFromSettings(cl,obj,(APTR)msg));
case Dis_ID_SaveLauncher : return(SaveLauncherSet(cl,obj));
case Dis_ID_LoadLauncher : return(LoadLauncherSet(cl,obj));
}
return(DoSuperMethodA(cl,obj,msg));
}
///
/*************************************************/
/* Main Window and his dispatcher */
/*************************************************/
/******************************************/
/* some vars */
/******************************************/
///
#define Dis_ID_DoubleClick1 1
#define Dis_ID_Finish 2
#define Dis_ID_DoubleClick2 3
#define Dis_ID_Save 4
#define Dis_ID_Snap 5
#define Dis_ID_Load 6
struct NewMenu MenuData1[] =
{
{ NM_TITLE, (STRPTR)MM_Project , 0 ,0 ,0 ,(APTR)MEN_PROJECT },
{ NM_ITEM , (STRPTR)MM_Open ,"O",0 ,0 ,(APTR)MEN_OPEN },
{ NM_ITEM , (STRPTR)MM_SaveAs ,"S",0 ,0 ,(APTR)MEN_SAVE },
{ NM_ITEM , (STRPTR)MM_About ,"?",0 ,0 ,(APTR)MEN_ABOUT },
{ NM_ITEM , NM_BARLABEL , 0 ,0 ,0 ,(APTR)0 },
{ NM_ITEM , (STRPTR)MM_Quit ,"Q",0 ,0 ,(APTR)MEN_QUIT },
{ NM_END,NULL,0,0,0,(APTR)0 }
};
struct ls_layout
{
char *entry_desc;
BYTE entry_selected;
BOOL entry_max;
char *entry[6];
};
struct ls_layout switches[]=
{
{(STRPTR)ML_Window, 0,0,0,0,0,0,0,0},
{(STRPTR)ML_BgPic, 0,2,(STRPTR)ML_BgPic_None,(STRPTR)ML_BgPic_File,(STRPTR)ML_BgPic_Snap,0,0,0},
{(STRPTR)ML_WinBeh, 0,2,(STRPTR)ML_WinBeh_Normal,(STRPTR)ML_WinBeh_Front,(STRPTR)ML_WinBeh_Back,0,0,0},
{(STRPTR)ML_WinMov, 0,1,(STRPTR)ML_WinMov_Normal,(STRPTR)ML_WinMov_Fixed,0,0,0,0},
{(STRPTR)ML_Border, 0,3,(STRPTR)ML_Border_None,(STRPTR)ML_Border_Simple,(STRPTR)ML_Border_Standard,(STRPTR)ML_Border_Double,0,0},
{(STRPTR)ML_Startup, 0,0,0,0,0,0,0,0},
{(STRPTR)ML_ScrNot, 0,1,(STRPTR)ML_ScrNot_No,(STRPTR)ML_ScrNot_Yes,0,0,0,0},
{(STRPTR)ML_Cpu, 0,2,(STRPTR)ML_Cpu_None,(STRPTR)ML_Cpu_Executive,(STRPTR)ML_Cpu_Own,0,0,0},
NULL
};
char *mainlister[]=
{
(STRPTR)MOL_General,
(STRPTR)MOL_Compose,
NULL
};
char *sublister[]=
{
(STRPTR)MOL_sub_General,
(STRPTR)MOL_sub_Flags,
(STRPTR)MOL_sub_Window,
NULL
};
struct MainData
{
ULONG dummy;
};
char *pubscr[256];
Object *BT_Save,
*BT_Use,
*BT_Test,
*BT_Cancel,
*ls_Switch,
*ls_PubScr,
*lv_Switch,
*lv_PubScr,
*ST_PubScr,
*PO_PubScr,
*MN_Main,
*WI_About,
*IN_posx,
*IN_posy,
*IN_sizx,
*ST_bg,
*NB_wait,
*NB_mem,
*NB_vol,
*NB_bordx,
*NB_bordy,
*NB_spcx,
*NB_spcy,
*NB_col,
*NB_pri,
*MN_Colors[3],
*CM_Falling,
*BT_Snap,
*LV_Composer;
///
/******************************************/
/* some listview hooks */
/******************************************/
///
__saveds __asm APTR lay_consfunc(__a1 struct ls_layout *src) { return(src); }
__saveds __asm ULONG lay_desfunc(__a1 struct ls_layout *src) { return(0L); }
__saveds __asm void lay_dispfunc(__a2 char **array,__a1 struct ls_layout *src)
{
*array++ = src->entry_desc;
*array = src->entry[src->entry_selected];
}
static const struct Hook lay_ConstructHook = { { 0,0 }, (void *)lay_consfunc, NULL, NULL };
static const struct Hook lay_DestructHook = { { 0,0 }, (void *)lay_desfunc , NULL, NULL };
static const struct Hook lay_DisplayHook = { { 0,0 }, (void *)lay_dispfunc, NULL, NULL };
///
/******************************************/
/* load settings and a method */
/******************************************/
///
#define load_standard 0
#define load_file 1
struct LoadSetMsg
{
ULONG MethodID;
ULONG what;
};
insertSettings(struct tm_sys_set *set,struct tm_gau_set *list)
{
struct ls_layout *src;
set(NB_col ,MUIA_Numeric_Value,set->colums);
set(NB_bordx,MUIA_Numeric_Value,set->win_border_x);
set(NB_bordy,MUIA_Numeric_Value,set->win_border_y);
set(NB_spcx ,MUIA_Numeric_Value,set->win_space_x);
set(NB_spcy ,MUIA_Numeric_Value,set->win_space_y);
set(NB_wait ,MUIA_Numeric_Value,set->start_wait);
set(NB_mem ,MUIA_Numeric_Value,set->mem_refresh);
set(NB_vol ,MUIA_Numeric_Value,set->vol_refresh);
set(NB_pri ,MUIA_Numeric_Value,set->pri);
DoMethod(ls_Switch,MUIM_List_GetEntry,1,&src);
src->entry_selected=set->bg_type;
DoMethod(ls_Switch,MUIM_List_GetEntry,2,&src);
src->entry_selected=set->win_backfront;
DoMethod(ls_Switch,MUIM_List_GetEntry,3,&src);
src->entry_selected=set->win_move;
DoMethod(ls_Switch,MUIM_List_GetEntry,4,&src);
src->entry_selected=set->bd_type;
DoMethod(ls_Switch,MUIM_List_GetEntry,6,&src);
src->entry_selected=set->start_usescreennotify;
DoMethod(ls_Switch,MUIM_List_GetEntry,7,&src);
src->entry_selected=set->Executive;
initColor(&set->bg_color,MN_Colors[0]);
initColor(&set->bright_color,MN_Colors[1]);
initColor(&set->dark_color,MN_Colors[2]);
set(ST_PubScr, MUIA_String_Contents ,&set->pub_name[0]);
set(IN_posx, MUIA_String_Integer ,set->x_pos);
set(IN_posy, MUIA_String_Integer ,set->y_pos);
set(IN_sizx, MUIA_String_Integer ,set->x_siz);
set(ST_bg, MUIA_String_Contents ,&set->bg_picture[0]);
set(CM_Falling, MUIA_Selected ,set->lay_falling);
DoMethod(visible,MUIM_List_Clear,0L);
do
{
DoMethod(visible,MUIM_List_InsertSingle,list,MUIV_List_Insert_Bottom);
}
while(list=list->next);
DoMethod(visible,MUIM_List_Redraw,MUIV_List_Redraw_All);
DoMethod(ls_Switch,MUIM_List_Redraw,MUIV_List_Redraw_All);
}
int getNum(struct tm_gau_set *list)
{
int num=1;
while(list=list->next)num++;
return(num);
}
useDefault(struct tm_data *data)
{
struct tm_gau_set *many,
*act,
*old;
CopyMem((char *)&default_set,data->set,sizeof(struct tm_sys_set));
if(act=(struct tm_gau_set *)AllocVec(sizeof(struct tm_gau_set),0L))
{
many=&g1; data->list=act; CopyMem((char *)many,act,sizeof(struct tm_gau_set));
while(many=many->next)
{
old=act;
if(act=(struct tm_gau_set *)AllocVec(sizeof(struct tm_gau_set),0L))
{
old->next=act;
CopyMem((char *)many,act,sizeof(struct tm_gau_set));
}
else {act->next=0L;return;}
}
act->next=0L;
}
else data->list=0L;
}
BOOL loadSettings(Object *obj,struct tm_data *data, char *file)
{
ULONG my_file;
struct tm_gau_set *many,*act;
if(!maindata->set)maindata->set=AllocVec(sizeof(struct tm_sys_set),0L);
if(my_file=(UBYTE *)Open(file,MODE_OLDFILE))
{
if(!Read(my_file,data->set,(ULONG)sizeof(struct tm_sys_set)))
{
useDefault(data);
}
else
{
act=(struct tm_gau_set *)AllocVec(sizeof(struct tm_gau_set),NULL);
data->list=act; many=act;
while(Read(my_file,(char *)act,(ULONG)sizeof(struct tm_gau_set)))
{
many=act;
act=(struct tm_gau_set *)AllocVec(sizeof(struct tm_gau_set),NULL);
many->next=act;
}
many->next=NULL; FreeVec(act); act=NULL;
}
Close(my_file);
}
else useDefault(data);
data->num_of_gaug=getNum(data->list);
}
ULONG loadManager(struct IClass *cl,Object *obj, struct LoadSetMsg *msg)
{
char *file;
switch (msg->what)
{
case load_standard:
loadSettings(obj,maindata,"ENV:TinyMeter");
insertSettings(maindata->set,maindata->list);
break;
case load_file:
if(file=getfilename(obj,GetStr(MM_OpenTitle),"#?.tm",FALSE))
{
loadSettings(obj,maindata,file);
insertSettings(maindata->set,maindata->list);
}
break;
}
return((ULONG)DoSuperMethodA(cl,obj,msg));
}
///
/******************************************/
/* test settings and window snapping */
/******************************************/
///
#include <exec/memory.h>
#include <exec/ports.h>
#include <exec/execbase.h>
#define test_test 0
#define test_getwin 1
struct TestMessage
{
struct Message ts_Message;
ULONG MethodID;
struct tm_sys_set *set;
struct tm_gau_set *list;
ULONG posx,
posy,
sizx;
};
struct TestMessage *ts_msg;
struct MsgPort *p_port;
struct MsgPort *p_reply;
BOOL SafePutToPort(struct Message *message, char *portname)
{
struct MsgPort *port;
Forbid();
port = (struct MsgPort *)FindPort(portname);
if (port) PutMsg(port, (struct Message *) message);
Permit();
return(port ? TRUE : FALSE);
}
ULONG InitTestSettings()
{
if(
( ts_msg =(struct TestMessage *)AllocMem (sizeof(struct TestMessage),MEMF_PUBLIC|MEMF_CLEAR)) &&
( p_reply=(struct MsgPort *) CreatePort(0,0))
) return (1L);
else return (0L);
}
FreeTestSettings()
{
if(ts_msg) FreeMem (ts_msg,sizeof(struct TestMessage));
if(p_reply)DeletePort (p_reply);
}
struct TestMessage *TestSettings(ULONG type)
{
ULONG i,j;
struct tm_gau_set *act,
*all[64];
if( FindPort("TinyMeter") )
if( ts_msg && p_reply)
{
ts_msg->ts_Message.mn_Node.ln_Type = NT_MESSAGE;
ts_msg->ts_Message.mn_ReplyPort = p_reply;
ts_msg->ts_Message.mn_Length = sizeof ( struct TestMessage );
ts_msg->MethodID = type;
switch (type)
{
case test_test:
for(i=0;i<64;i++)all[i]=0L;
for(i=0;;i++)
{
DoMethod(visible,MUIM_List_GetEntry,i,&act);
if(!act) break;
if(i==63) break;
if(all[i]=AllocVec(sizeof(struct tm_gau_set),0L))
{
CopyMem(act, all[i], sizeof(struct tm_gau_set));
}
else return(0L);
}
for(j=0;j<i;j++)
{
all[j]->next=all[j+1];
}
ts_msg->list=all[0];
if(ts_msg->set = AllocVec(sizeof(struct tm_sys_set),0L))
{
CopyMem(maindata->set,ts_msg->set,sizeof(struct tm_sys_set));
}
else return(0L);
break;
case test_getwin:
ts_msg->list=0L;
ts_msg->set =0L;
break;
}
if (SafePutToPort((struct Message *)ts_msg,"TinyMeter"))
{
WaitPort(p_reply);
return(GetMsg(p_reply));
}
}
return(0L);
}
///
/******************************************/
/* snapWindow method */
/******************************************/
///
snapWindow(struct IClass *cl,Object *obj, struct Msg *msg)
{
struct TestMessage *testMsg;
testMsg=TestSettings(test_getwin);
set(IN_posx, MUIA_String_Integer ,testMsg->posx);
set(IN_posy, MUIA_String_Integer ,testMsg->posy);
set(IN_sizx, MUIA_String_Integer ,testMsg->sizx);
}
///
/******************************************/
/* save settings and the method for it */
/******************************************/
///
#define save_save 0
#define save_use 1
#define save_test 2
#define save_file 3
#define save_cancel 4
struct SaveSetMsg
{
ULONG MethodID;
ULONG what;
};
getSettings(struct tm_sys_set *set)
{
ULONG dummy;
struct ls_layout *src;
get(NB_col ,MUIA_Numeric_Value,&dummy);set->colums =(UWORD)dummy;
get(NB_bordx,MUIA_Numeric_Value,&dummy);set->win_border_x =(UWORD)dummy;
get(NB_bordy,MUIA_Numeric_Value,&dummy);set->win_border_y =(UWORD)dummy;
get(NB_spcx ,MUIA_Numeric_Value,&dummy);set->win_space_x =(UWORD)dummy;
get(NB_spcy ,MUIA_Numeric_Value,&dummy);set->win_space_y =(UWORD)dummy;
get(NB_wait ,MUIA_Numeric_Value,&dummy);set->start_wait =(UWORD)dummy;
get(NB_mem ,MUIA_Numeric_Value,&dummy);set->mem_refresh =(UWORD)dummy;
get(NB_vol ,MUIA_Numeric_Value,&dummy);set->vol_refresh =(UWORD)dummy;
get(NB_pri ,MUIA_Numeric_Value,&dummy);set->pri =(BYTE) dummy;
get(CM_Falling,MUIA_Selected, &dummy);set->lay_falling =(UBYTE)dummy;
DoMethod(ls_Switch,MUIM_List_GetEntry,1,&src); set->bg_type =src->entry_selected;
DoMethod(ls_Switch,MUIM_List_GetEntry,2,&src); set->win_backfront =src->entry_selected;
DoMethod(ls_Switch,MUIM_List_GetEntry,3,&src); set->win_move =src->entry_selected;
DoMethod(ls_Switch,MUIM_List_GetEntry,4,&src); set->bd_type =src->entry_selected;
DoMethod(ls_Switch,MUIM_List_GetEntry,6,&src); set->start_usescreennotify=src->entry_selected;
DoMethod(ls_Switch,MUIM_List_GetEntry,7,&src); set->Executive =src->entry_selected;
getColor(&set->bg_color, MN_Colors[0]);
getColor(&set->bright_color,MN_Colors[1]);
getColor(&set->dark_color, MN_Colors[2]);
get(ST_PubScr ,MUIA_String_Contents,&dummy); strcpy(&set->pub_name[0] ,(char *)dummy);
get(ST_bg ,MUIA_String_Contents,&dummy); strcpy(&set->bg_picture[0] ,(char *)dummy);
get(IN_sizx ,MUIA_String_Integer, &dummy); set->x_siz=(UWORD)dummy;
get(IN_posx ,MUIA_String_Integer, &dummy); set->x_pos=(UWORD)dummy;
get(IN_posy ,MUIA_String_Integer, &dummy); set->y_pos=(UWORD)dummy;
}
static saveSettings(Object *listv, struct tm_sys_set *set, char *file)
{
int i;
ULONG my_file;
struct tm_gau_set *act;
if(my_file=(ULONG)Open(file,MODE_NEWFILE))
{
Write(my_file,set,(ULONG)sizeof(struct tm_sys_set));
for (i=0;;i++)
{
DoMethod(listv,MUIM_List_GetEntry,i,&act);
if(!act) break;
if(i==63) break;
Write(my_file,act,(ULONG)sizeof(struct tm_gau_set));
}
Close(my_file);
}
}
ULONG saveManager(struct IClass *cl,Object *obj, struct SaveSetMsg *msg)
{
int i=0;
char *file;
getSettings(maindata->set);
switch (msg->what)
{
case save_save:
saveSettings(visible,maindata->set,"ENVARC:TinyMeter");
case save_use:
saveSettings(visible,maindata->set,"ENV:TinyMeter");
TestSettings(test_test);
while(pubscr[i]) FreeVec(pubscr[i++]);
DoMethod((Object *)xget(obj,MUIA_ApplicationObject),MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
return(0L);
case save_test:
TestSettings(test_test);
return(obj);
case save_file:
if(file=getfilename(obj,GetStr(MM_SaveTitle),"#?.tm",TRUE))
saveSettings(visible,maindata->set,file);
break;
case save_cancel:
loadSettings(obj,maindata,"ENV:TinyMeter");
insertSettings(maindata->set,maindata->list);
TestSettings(test_test);
DoMethod((Object *)xget(obj,MUIA_ApplicationObject),MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
break;
}
return((ULONG)DoSuperMethodA(cl,obj,msg));
}
///
/******************************************/
/* other MainWindow methods */
/******************************************/
///
struct DoubleClkMsg
{
ULONG MethodID;
struct MainData *data;
};
static ULONG Dis_DoubleClick2(struct IClass *cl,Object *obj, struct DoubleClkMsg *msg)
{
struct ls_layout *src;
DoMethod(ls_Switch,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&src);
if(src)
{
if(src->entry_max>0)
{
src->entry_selected++;if(src->entry_max<src->entry_selected)src->entry_selected=0;
DoMethod(ls_Switch,MUIM_List_Redraw,MUIV_List_Redraw_Active);
}
return(DoSuperMethodA(cl,obj,msg));
}
else return(0L);
}
static ULONG Dis_DoubleClick1(struct IClass *cl,Object *obj, struct DoubleClkMsg *msg)
{
char *my_ptr;
DoMethod(ls_PubScr,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&my_ptr);
if(my_ptr)
{
set(ST_PubScr,MUIA_String_Contents,my_ptr);
DoMethod(PO_PubScr,MUIM_Popstring_Close,0L);
return(DoSuperMethodA(cl,obj,msg));
}
else return(0L);
}
ULONG MainWindow_Finish(struct IClass *cl,Object *obj,Msg *msg)
{
int i=0;
struct MainData *data;
data=INST_DATA(cl,obj);
while(pubscr[i++]) FreeVec(pubscr[i]); pubscr[i]=0;
DoMethod((Object *)xget(obj,MUIA_ApplicationObject),MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
return((ULONG)0L);
}
static GetPubScreens()
{
struct List *PubScreenList;
struct PubScreenNode *ScreenNode;
int i=0;
PubScreenList = LockPubScreenList();
for(ScreenNode=(struct PubScreenNode *)PubScreenList->lh_Head;ScreenNode->psn_Node.ln_Succ;ScreenNode=(struct PubScreenNode *)ScreenNode->psn_Node.ln_Succ)
{
pubscr[i]=(char *)AllocVec(256L,0L);
strcpy(pubscr[i],ScreenNode->psn_Node.ln_Name);
i++;
}
UnlockPubScreenList();
}
static ULONG MainWindow_New(struct IClass *cl,Object *obj,Msg *msg)
{
struct MainData *data;
int i;
GetPubScreens();
if (obj = (Object *)
DoSuperNew(cl,obj,
MUIA_Window_Title, GetStr(MO_Title),
MUIA_Window_ID , MAKE_ID('T','I','N','Y'),
WindowContents, VGroup, ButtonFrame,
Child, HGroup,
Child, VGroup, MUIA_Background, MUII_SHADOW,
Child, HVSpace,
Child, BodychunkObject,
MUIA_FixWidth , LOGO_WIDTH ,
MUIA_FixHeight , LOGO_HEIGHT,
MUIA_Bitmap_Width , LOGO_WIDTH ,
MUIA_Bitmap_Height , LOGO_HEIGHT,
MUIA_Bodychunk_Depth , LOGO_DEPTH ,
MUIA_Bodychunk_Body , (UBYTE *)logo_body,
MUIA_Bodychunk_Compression, LOGO_COMPRESSION,
MUIA_Bodychunk_Masking , LOGO_MASKING,
MUIA_Bitmap_SourceColors , (ULONG *)logo_colors,
MUIA_Bitmap_Transparent , 0,
MUIA_ShortHelp, "Greets to: hANGKOK, pEPE, bEZZZERK, tRACER, rALPH...",
End,
End,
Child, RegisterGroup(mainlister),
MUIA_Register_Frame, TRUE,
Child, HGroup,
Child, RegisterGroup(sublister),
MUIA_Register_Frame, TRUE,
Child, HGroup,
Child, ColGroup(2), GroupFrameT(GetStr(MOL_Handler)),
Child, HVSpace,
Child, HVSpace,
Child, Label(GetStr(MO_MemRefresh)),
Child, ColGroup(2), Child, NB_mem=MUI_MakeObject(MUIO_NumericButton,NULL,1,100,GetStr(MO_fmt_seconds)), Child, HVSpace, End,
Child, Label(GetStr(MO_VolRefresh)),
Child, ColGroup(2), Child, NB_vol=MUI_MakeObject(MUIO_NumericButton,NULL,1,100,GetStr(MO_fmt_seconds)), Child, HVSpace, End,
Child, Label(GetStr(MO_Wait)),
Child, ColGroup(2), Child, NB_wait=MUI_MakeObject(MUIO_NumericButton,NULL,0,100,GetStr(MO_fmt_seconds)), Child, HVSpace, End,
Child, Label(GetStr(MO_TaskPrio)),
Child, ColGroup(2), Child, NB_pri=MUI_MakeObject(MUIO_NumericButton,NULL,-128,127,"%ld"), Child, HVSpace, End,
Child, HVSpace,
Child, HVSpace,
End,
Child, ColGroup(2), GroupFrameT(GetStr(MOL_sub_Layout)),
Child, HVSpace,
Child, HVSpace,
Child, Label(GetStr(MO_Colums)),
Child, ColGroup(2), Child, NB_col=MUI_MakeObject(MUIO_NumericButton,NULL,1,32,"%3ld"), Child, HVSpace, End,
Child, Label(GetStr(MO_FallingCol)),
Child, HGroup, Child, CM_Falling=CheckMark(NULL), Child, HVSpace, End,
Child, Label(GetStr(MO_SpaceX)),
Child, ColGroup(2), Child, NB_spcx=MUI_MakeObject(MUIO_NumericButton,NULL,0,256,GetStr(MO_fmt_pixels)), Child, HVSpace, End,
Child, Label(GetStr(MO_SpaceY)),
Child, ColGroup(2), Child, NB_spcy=MUI_MakeObject(MUIO_NumericButton,NULL,0,256,GetStr(MO_fmt_pixels)), Child, HVSpace, End,
Child, Label(GetStr(MO_BordX)),
Child, ColGroup(2), Child, NB_bordx=MUI_MakeObject(MUIO_NumericButton,NULL,0,256,GetStr(MO_fmt_pixels)), Child, HVSpace, End,
Child, Label(GetStr(MO_BordY)),
Child, ColGroup(2), Child, NB_bordy=MUI_MakeObject(MUIO_NumericButton,NULL,0,256,GetStr(MO_fmt_pixels)), Child, HVSpace, End,
Child, HVSpace,
Child, HVSpace,
End,
End,
Child, lv_Switch=(Object *)ListviewObject,
MUIA_Listview_Input, TRUE,
MUIA_Listview_DoubleClick, TRUE,
MUIA_Listview_List, ls_Switch=(Object *)ListObject,
MUIA_Frame, MUIV_Frame_InputList,
MUIA_List_ConstructHook, &lay_ConstructHook,
MUIA_List_DestructHook , &lay_DestructHook,
MUIA_List_DisplayHook , &lay_DisplayHook,
MUIA_List_Format , "MIW=5 MAW=100 BAR,",
MUIA_List_Active, MUIV_List_Active_Top,
End,
End,
Child, ColGroup(2),
Child, HVSpace,
Child, HVSpace,
Child, Label(GetStr(MO_Public)),
Child, PO_PubScr=(Object *)PopobjectObject,
MUIA_Popstring_String, ST_PubScr=(Object *)String(NULL,80),
MUIA_Popstring_Button, PopButton(MUII_PopUp),
MUIA_Popobject_Object, lv_PubScr=(Object *)ListviewObject,
MUIA_Listview_Input, TRUE,
MUIA_Listview_DoubleClick, TRUE,
MUIA_Listview_List, ls_PubScr=(Object *)ListObject,
MUIA_Frame, MUIV_Frame_InputList,
MUIA_List_Active, MUIV_List_Active_Top,
MUIA_List_SourceArray,&pubscr[0],
End,
End,
End,
Child, Label(GetStr(MO_WindowPos)),
Child, ColGroup(2),
Child, IN_posx=StringObject,
StringFrame,
MUIA_String_Accept , "0123456879",
End,
Child, IN_posy=StringObject,
StringFrame,
MUIA_String_Accept , "0123456879",
End,
End,
Child, Label(GetStr(MO_WindowSiz)),
Child, ColGroup(2),
MUIA_Group_SameWidth, TRUE,
Child, IN_sizx=StringObject,
StringFrame,
MUIA_String_Accept , "0123456879",
End,
Child, BT_Snap=SimpleButton(GetStr(MO_Snap)),
End,
Child, Label(GetStr(MO_BackgroundPic)),
Child, ST_bg=PopaslObject,
MUIA_Popstring_String, String(NULL,80),
MUIA_Popstring_Button, PopButton(MUII_PopFile),
ASLFO_TitleText , GetStr(MO_SelectBg),
End,
Child, Label(GetStr(MO_BackgroundCol)),
Child, ColGroup(2),Child, MN_Colors[0]=MakePen(), Child, HVSpace, End,
Child, Label(GetStr(MO_BrightCol)),
Child, ColGroup(2),Child, MN_Colors[1]=MakePen(), Child, HVSpace, End,
Child, Label(GetStr(MO_DarkCol)),
Child, ColGroup(2),Child, MN_Colors[2]=MakePen(), Child, HVSpace, End,
Child, HVSpace,
Child, HVSpace,
End,
End,
End,
Child, VGroup,
Child, NewObject(CL_ChooseFields->mcc_Class,NULL,TAG_DONE),
End,
End,
End,
Child, HGroup,
Child, BT_Save = (Object *)SimpleButton(GetStr(MO_Save)),
Child, BT_Use = (Object *)SimpleButton(GetStr(MO_Use)),
Child, BT_Test = (Object *)SimpleButton(GetStr(MO_Test)),
Child, BT_Cancel = (Object *)SimpleButton(GetStr(MO_Cancel)),
End,
End,
End)
{
data=INST_DATA(cl,obj);
set(BT_Save ,MUIA_ShortHelp,GetStr(MH_Save));
set(BT_Use ,MUIA_ShortHelp,GetStr(MH_Use));
set(BT_Test ,MUIA_ShortHelp,GetStr(MH_Test));
set(BT_Cancel ,MUIA_ShortHelp,GetStr(MH_Cancel));
set(NB_mem ,MUIA_ShortHelp,GetStr(MH_MemRefresh));
set(NB_vol ,MUIA_ShortHelp,GetStr(MH_VolRefresh));
set(NB_wait ,MUIA_ShortHelp,GetStr(MH_Wait));
set(lv_Switch ,MUIA_ShortHelp,GetStr(MH_Flags));
set(PO_PubScr ,MUIA_ShortHelp,GetStr(MH_Public));
set(IN_posx ,MUIA_ShortHelp,GetStr(MH_PosX));
set(IN_posy ,MUIA_ShortHelp,GetStr(MH_PosY));
set(IN_sizx ,MUIA_ShortHelp,GetStr(MH_SizX));
set(BT_Snap ,MUIA_ShortHelp,GetStr(MH_Snap));
set(ST_bg ,MUIA_ShortHelp,GetStr(MH_BackgroundPic));
set(MN_Colors[0],MUIA_ShortHelp,GetStr(MH_BackgroundCol));
set(MN_Colors[1],MUIA_ShortHelp,GetStr(MH_BrightCol));
set(MN_Colors[2],MUIA_ShortHelp,GetStr(MH_DarkCol));
set(NB_col ,MUIA_ShortHelp,GetStr(MH_Colums));
set(NB_spcx ,MUIA_ShortHelp,GetStr(MH_SpaceX));
set(NB_spcy ,MUIA_ShortHelp,GetStr(MH_SpaceX));
set(NB_bordx ,MUIA_ShortHelp,GetStr(MH_BordX));
set(NB_bordy ,MUIA_ShortHelp,GetStr(MH_BordY));
DoMethod(BT_Snap ,MUIM_Notify,MUIA_Pressed ,FALSE ,obj,1,Dis_ID_Snap);
DoMethod(BT_Save ,MUIM_Notify,MUIA_Pressed ,FALSE ,obj,2,Dis_ID_Save,save_save);
DoMethod(BT_Use ,MUIM_Notify,MUIA_Pressed ,FALSE ,obj,2,Dis_ID_Save,save_use );
DoMethod(BT_Test ,MUIM_Notify,MUIA_Pressed ,FALSE ,obj,2,Dis_ID_Save,save_test);
DoMethod(lv_PubScr,MUIM_Notify,MUIA_Listview_DoubleClick ,TRUE ,obj,2,Dis_ID_DoubleClick1,data);
DoMethod(lv_Switch,MUIM_Notify,MUIA_Listview_DoubleClick ,TRUE ,obj,1,Dis_ID_DoubleClick2);
DoMethod(obj ,MUIM_Notify,MUIA_Window_MenuAction ,MEN_SAVE,obj,2,Dis_ID_Save,save_file);
DoMethod(obj ,MUIM_Notify,MUIA_Window_MenuAction ,MEN_OPEN,obj,2,Dis_ID_Load,load_file);
DoMethod(BT_Cancel,MUIM_Notify,MUIA_Pressed ,FALSE ,obj,2,Dis_ID_Save,save_cancel);
for(i=0;i<8;i++)DoMethod(ls_Switch,MUIM_List_InsertSingle,&switches[i],MUIV_List_Insert_Bottom);
DoMethod(obj ,Dis_ID_Load,load_standard);
}
return((ULONG)obj);
}
///
static __saveds __asm ULONG MainWindowDispatcher(__a0 struct IClass *cl,__a2 Object *obj,__a1 Msg msg)
{
switch (msg->MethodID)
{
case OM_NEW : return (MainWindow_New (cl,obj,(APTR)msg));
case Dis_ID_Finish : return (MainWindow_Finish (cl,obj,(APTR)msg));
case Dis_ID_DoubleClick1 : return (Dis_DoubleClick1 (cl,obj,(APTR)msg));
case Dis_ID_DoubleClick2 : return (Dis_DoubleClick2 (cl,obj,(APTR)msg));
case Dis_ID_Save : return (saveManager (cl,obj,(APTR)msg));
case Dis_ID_Snap : return (snapWindow (cl,obj,(APTR)msg));
case Dis_ID_Load : return (loadManager (cl,obj,(APTR)msg));
}
return (DoSuperMethodA (cl,obj,(APTR)msg));
}
/*************************************************/
/* Init all classes */
/*************************************************/
///
VOID ExitClasses(VOID)
{
if (CL_FieldsList ) MUI_DeleteCustomClass(CL_FieldsList);
if (CL_ChooseFields) MUI_DeleteCustomClass(CL_ChooseFields);
if (CL_MainWindow) MUI_DeleteCustomClass(CL_MainWindow);
if (CL_Composer) MUI_DeleteCustomClass(CL_Composer);
if (CL_Launcher) MUI_DeleteCustomClass(CL_Launcher);
}
BOOL InitClasses(VOID)
{
CL_MainWindow = MUI_CreateCustomClass(NULL,MUIC_Window ,NULL, sizeof(struct MainData) ,MainWindowDispatcher);
CL_FieldsList = MUI_CreateCustomClass(NULL,MUIC_List ,NULL, sizeof(struct FieldsList_Data) ,FieldsList_Dispatcher);
CL_ChooseFields = MUI_CreateCustomClass(NULL,MUIC_Group ,NULL, sizeof(struct ChooseFields_Data) ,ChooseFields_Dispatcher);
CL_Composer = MUI_CreateCustomClass(NULL,MUIC_Window ,NULL, sizeof(struct Composer_Data) ,ComposerDispatcher);
CL_Launcher = MUI_CreateCustomClass(NULL,MUIC_Window ,NULL, sizeof(struct Launcher_Data) ,LauncherDispatcher);
if ( CL_FieldsList && CL_ChooseFields && CL_MainWindow && CL_Composer && CL_Launcher ) return(TRUE);
ExitClasses();
return(FALSE);
}
///
/*************************************************/
/* Main: MUIApplication and Aboutwindow */
/*************************************************/
///
#include <exec/tasks.h>
#ifdef _DCC
int brkfunc(void) { return(0); }
#endif
void LocalizeSwitches(struct ls_layout *ll)
{
int i;
for (;ll->entry_desc!=NULL;ll++)
{
ll->entry_desc=GetStr((int)ll->entry_desc);
for(i=0;i<6;i++)
{
if (ll->entry[i]!=NULL) ll->entry[i]=GetStr((int)ll->entry[i]);
else ll->entry[i]=" ";
}
}
}
int main(int argc, char *argv[])
{
Object *app,
*window;
struct Task *me;
if (MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN))
{
if(me=FindTask(NULL))
{
if((me->tc_SPUpper-me->tc_SPLower)>8000)
{
if(maindata=(struct tm_data *)AllocVec(sizeof(struct tm_data),MEMF_CLEAR))
{
if(InitTestSettings())
{
InitClasses();
InitLocale();
LocalizeNewMenu(MenuData1);
LocalizeNewMenu(CmpMenuData);
LocalizeNewMenu(LauMenuData);
LocalizeSwitches(switches);
LocalizeStringArray(gau_types);
LocalizeStringArray(types);
LocalizeStringArray(indent);
LocalizeStringArray(mainlister);
LocalizeStringArray(sublister);
LocalizeStringArray(regcomposer);
LocalizeStringArray(reglauncher);
LocalizeStringArray(cyplace);
LocalizeStringArray(cyindent);
strcpy(&default_gauge.label[0],GetStr(MDef_Label));
strcpy(&default_gauge.format[0],GetStr(MDef_fmt));
strcpy(&default_gauge.expansion[0],GetStr(MDef_Device));
app = ApplicationObject,
MUIA_Application_Title , "TinyMeterPrefs V4.20",
MUIA_Application_Version , "$VER: TinyMeterPrefs V4.20 (14.5.96)",
MUIA_Application_Copyright , "©1994-96, Tinic Urou",
MUIA_Application_Author , "Tinic Urou",
MUIA_Application_Description, GetStr(MA_Description),
MUIA_Application_Base , "TMPREFS",
MUIA_Application_HelpFile , "HELP:TinyMeter.guide",
MUIA_Application_Menustrip , MN_Main = MUI_MakeObject(MUIO_MenustripNM,MenuData1,0),
SubWindow , window = (Object *)NewObject(CL_MainWindow->mcc_Class,NULL,TAG_DONE),
SubWindow , WI_About = WindowObject,
MUIA_Window_Title, GetStr(MA_About_Title),
MUIA_Window_ID , MAKE_ID('T','M','A','B'),
WindowContents, VGroup, ButtonFrame,
Child, BodychunkObject,
MUIA_FixWidth , ABOUT_WIDTH ,
MUIA_FixHeight , ABOUT_HEIGHT,
MUIA_Bitmap_Width , ABOUT_WIDTH ,
MUIA_Bitmap_Height , ABOUT_HEIGHT,
MUIA_Bodychunk_Depth , ABOUT_DEPTH ,
MUIA_Bodychunk_Body , (UBYTE *)about_body,
MUIA_Bodychunk_Compression, ABOUT_COMPRESSION,
MUIA_Bodychunk_Masking , ABOUT_MASKING,
MUIA_Bitmap_SourceColors , (ULONG *)about_colors,
MUIA_Bitmap_Transparent , 0,
End,
End,
End,
SubWindow , WI_HelpFmt = WindowObject,
MUIA_Window_Title, GetStr(MH_FormatHelp),
MUIA_Window_ID , MAKE_ID('T','H','L','P'),
MUIA_Window_UseRightBorderScroller, TRUE,
MUIA_Window_UseBottomBorderScroller, TRUE,
WindowContents, VGroup,
Child, ScrollgroupObject,
MUIA_Scrollgroup_UseWinBorder, TRUE,
MUIA_Scrollgroup_Contents, VirtgroupObject,TextFrame,
Child, TextObject,
MUIA_Text_Contents, GetStr(MOH_Format),
End,
End,
End,
End,
End,
SubWindow , WI_HelpClock = WindowObject,
MUIA_Window_Title, GetStr(MH_ClockHelp),
MUIA_Window_ID , MAKE_ID('T','H','L','P'),
MUIA_Window_UseRightBorderScroller, TRUE,
MUIA_Window_UseBottomBorderScroller, TRUE,
WindowContents, VGroup,
Child, ScrollgroupObject,
MUIA_Scrollgroup_UseWinBorder, TRUE,
MUIA_Scrollgroup_Contents, VirtgroupObject,TextFrame,
Child, TextObject,
MUIA_Text_Contents, GetStr(MOH_Clock),
End,
End,
End,
End,
End,
End;
if(app)
{
DoMethod(app ,MUIM_Notify,MUIA_Application_MenuAction,MEN_QUIT ,app , 2,MUIM_Application_ReturnID ,MUIV_Application_ReturnID_Quit);
DoMethod(app ,MUIM_Notify,MUIA_Application_MenuAction,MEN_ABOUT,WI_About, 3,MUIM_Set ,MUIA_Window_Open,TRUE);
DoMethod(WI_About ,MUIM_Notify,MUIA_Window_CloseRequest ,TRUE ,WI_About, 3,MUIM_Set ,MUIA_Window_Open,FALSE);
DoMethod(WI_HelpFmt ,MUIM_Notify,MUIA_Window_CloseRequest ,TRUE ,WI_HelpFmt, 3,MUIM_Set ,MUIA_Window_Open,FALSE);
DoMethod(WI_HelpClock,MUIM_Notify,MUIA_Window_CloseRequest ,TRUE ,WI_HelpClock,3,MUIM_Set ,MUIA_Window_Open,FALSE);
DoMethod(window, MUIM_Notify,MUIA_Window_CloseRequest ,TRUE ,app, 2,MUIM_Application_ReturnID ,MUIV_Application_ReturnID_Quit);
set(window,MUIA_Window_Open,TRUE);
{
ULONG sigs = 0;
while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
{
if (sigs)
{
sigs = Wait(sigs | SIGBREAKF_CTRL_C);
if (sigs & SIGBREAKF_CTRL_C) break;
}
}
}
MUI_DisposeObject(app);
}
ExitLocale();
ExitClasses();
FreeTestSettings();
}
if(maindata->set)FreeVec(maindata->set);
FreeVec(maindata);
}
}
else MUI_RequestA(NULL,NULL,0,"Early Startup","OK","Stacksize too small!\n\nA minimum of 8192 bytes is needed.",NULL);
}
CloseLibrary(MUIMasterBase);
}
return(0);
}
int wbmain(struct WBStartup *wb_startup)
{
return(main(0, (char **)wb_startup));
}
///